Skip to content

Commit 1b4d042

Browse files
authored
Move RBM_SAVED_LOCALLOC_SP reservation from compCompile to setFrameType in LSRA (#121745)
Move the code that adds `RBM_SAVED_LOCALLOC_SP` to `rsMaskResvd` from `compCompile` into `setFrameType` in LSRA ## Plan - [x] Understand the problem: Need to move ARM-specific code that reserves a register for localloc stack unwinding - [x] Locate source code: - Code to move: `compiler.cpp` lines 4953-4959 (inside `compCompile`) - Destination: `lsra.cpp` `setFrameType()` function after line 2718 - [x] Verify baseline build (CoreCLR) succeeds - [x] 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 - [x] Build CoreCLR to verify compilation succeeds - [x] Address review feedback: Add JITDUMP statement for register reservation - [x] Build CoreCLR again to verify JITDUMP addition - [x] Run CodeQL security scan - No issues found - [x] 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. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > 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` </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/dotnet/runtime/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
1 parent 5478a0e commit 1b4d042

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4950,14 +4950,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
49504950
// call and register argument info, flowgraph and loop info, etc.
49514951
compJitStats();
49524952

4953-
#ifdef TARGET_ARM
4954-
if (compLocallocUsed)
4955-
{
4956-
// We reserve REG_SAVED_LOCALLOC_SP to store SP on entry for stack unwinding
4957-
codeGen->regSet.rsMaskResvd |= RBM_SAVED_LOCALLOC_SP;
4958-
}
4959-
#endif // TARGET_ARM
4960-
49614953
if (compIsAsync())
49624954
{
49634955
DoPhase(this, PHASE_ASYNC, &Compiler::TransformAsync);

src/coreclr/jit/lsra.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,16 @@ void LinearScan::setFrameType()
25882588
}
25892589
#endif // TARGET_ARMARCH || TARGET_RISCV64
25902590

2591+
#ifdef TARGET_ARM
2592+
if (compiler->compLocallocUsed)
2593+
{
2594+
// We reserve REG_SAVED_LOCALLOC_SP to store SP on entry for stack unwinding
2595+
compiler->codeGen->regSet.rsMaskResvd |= RBM_SAVED_LOCALLOC_SP;
2596+
JITDUMP(" Reserved REG_SAVED_LOCALLOC_SP (%s) due to localloc\n", getRegName(REG_SAVED_LOCALLOC_SP));
2597+
removeMask |= RBM_SAVED_LOCALLOC_SP.GetIntRegSet();
2598+
}
2599+
#endif // TARGET_ARM
2600+
25912601
if ((removeMask != RBM_NONE) && ((availableIntRegs & removeMask) != 0))
25922602
{
25932603
// We know that we're already in "read mode" for availableIntRegs. However,

0 commit comments

Comments
 (0)