Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Move the code that adds RBM_SAVED_LOCALLOC_SP to rsMaskResvd from compCompile into setFrameType in LSRA

Plan

  • Understand the problem: Need to move ARM-specific code that reserves a register for localloc stack unwinding
  • Locate source code:
    • Code to move: compiler.cpp lines 4953-4959 (inside compCompile)
    • Destination: lsra.cpp setFrameType() function after line 2718
  • Verify baseline build (CoreCLR) succeeds
  • Make the code change:
    • Removed the code block from compiler.cpp (lines 4953-4959)
    • Added the code block to lsra.cpp in setFrameType() after existing rsMaskResvd setting
  • Build CoreCLR to verify compilation succeeds
  • Address review feedback: Add JITDUMP statement for register reservation
  • Build CoreCLR again to verify JITDUMP addition
  • Run CodeQL security scan - No issues found
  • Complete

Changes Made

  • src/coreclr/jit/compiler.cpp: Removed the #ifdef TARGET_ARM block that sets RBM_SAVED_LOCALLOC_SP in rsMaskResvd from the compCompile function
  • src/coreclr/jit/lsra.cpp: Added the same block to setFrameType() after the existing code that sets rsMaskResvd for large frame offsets
  • src/coreclr/jit/lsra.cpp: Added JITDUMP statement to log when REG_SAVED_LOCALLOC_SP is reserved

Build Status

✅ CoreCLR build succeeded with changes
✅ CoreCLR build succeeded with JITDUMP addition
✅ No CodeQL security issues detected

Security Summary

No security vulnerabilities were introduced or detected in this change. The code is a straightforward refactoring that moves existing logic to a more appropriate location without changing its behavior.

Original prompt

Move the code that adds RBM_SAVED_LOCALLOC_SP to rsMaskResvd from compCompile into setFrameType in LSRA, next to the existing code that sets rsMaskResvd


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 18, 2025
@jakobbotsch jakobbotsch added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 18, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot AI changed the title [WIP] Move RBM_SAVED_LOCALLOC_SP assignment to setFrameType Move RBM_SAVED_LOCALLOC_SP reservation from compCompile to setFrameType in LSRA Nov 18, 2025
Copilot AI requested a review from jakobbotsch November 18, 2025 15:12
Copilot finished work on behalf of jakobbotsch November 18, 2025 15:12
Comment on lines +2723 to +2724
// We reserve REG_SAVED_LOCALLOC_SP to store SP on entry for stack unwinding
compiler->codeGen->regSet.rsMaskResvd |= RBM_SAVED_LOCALLOC_SP;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a JITDUMP like the one above about the fact that we are reserving this register?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Can you add a JITDUMP like the one above about the fact that we are reserving this register?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 8da758e

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot AI requested a review from jakobbotsch November 18, 2025 16:50
Copilot finished work on behalf of jakobbotsch November 18, 2025 16:50
@jakobbotsch jakobbotsch marked this pull request as ready for review November 18, 2025 17:49
Copilot AI review requested due to automatic review settings November 18, 2025 17:49
Copilot finished reviewing on behalf of jakobbotsch November 18, 2025 17:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR relocates ARM-specific register reservation code from the compCompile function to the setFrameType function in LSRA. The change moves the logic that reserves RBM_SAVED_LOCALLOC_SP (R9 on ARM) for stack unwinding when localloc is used, placing it closer to related register reservation code.

Key changes:

  • Removes the #ifdef TARGET_ARM block from compCompile in compiler.cpp
  • Adds the same logic to setFrameType in lsra.cpp, positioned after the RBM_OPT_RSVD reservation code
  • Includes a new JITDUMP statement for debugging visibility when the register is reserved

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/jit/compiler.cpp Removed ARM-specific register reservation block from compCompile function
src/coreclr/jit/lsra.cpp Added ARM-specific register reservation to setFrameType with JITDUMP logging

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants