Repository navigation
JIT: preserve post-call nops during late jump removal - #137261
Conversation
dotnet#95493 allowed removing post-call jumps to next without introducing nops, keeping nops only before epilogs. Subsequently, dotnet#95565 enabled asynchronous interruption at call-return safepoints, reintroducing the need for post-call nop padding when the instruction after a call is a join and incoming GC state differs from the call-return state. Fixes dotnet#135384 Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
@dotnet/jit-contrib ptal Seems like we have gone back and forth on this, but the nops are needed in some cases. |
There was a problem hiding this comment.
🟡 Changes recommended
The regression assertion passes even with the unfixed JIT, so an x64 codegen check is needed to detect missing EH-boundary padding and fail when the fix is reverted.
1 open issue
What changed in this PR
This PR fixes x64 JIT late jump removal so deleting a jump immediately after a call preserves a one-byte nop. This keeps call-return GC state separate from branch-target state and preserves exception-handling boundaries.
Changes:
- Preserve post-call padding regardless of whether the target is an OS epilog.
- Rename the jump flag and update emission checks and diagnostics.
- Add GC-liveness regression cases and an exception-handler boundary test.
| File | Description |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_135384.cs |
Adds GC-state and exception-handler test scenarios. |
src/coreclr/jit/emitxarch.cpp |
Tracks post-call jumps and emits replacement nops. |
src/coreclr/jit/emit.h |
Renames and documents the post-call jump flag. |
src/coreclr/jit/emit.cpp |
Retains one-byte padding during late jump removal and updates diagnostics. |
Review effort: Balanced
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
LGTM. Jump removal runs after prolog/epilog generation and before distance binding and alignment, without an optimization-tier guard. The one-byte replacement is reflected in layout accounting and actual emission. Branches that remain cannot enter the NOP-emission path. |

Preserve a one-byte nop when late jump-to-next removal deletes a jump
immediately after a call. This keeps the call-return PC separate from a
branch target with different GC state, and preserves padding at EH boundaries.
#95493 allowed removing these jumps while retaining nops only
before OS epilogs. #95565 subsequently enabled asynchronous
interruption at call-return safepoints. The label-time padding check misses
the call when the removable jump is still present.
Adds a GC-liveness regression and EH-boundary coverage.
Validation
Windows x64, Checked CoreCLR with Release libraries and a matching Core_Root:
DOTNET_GCStress=4; the fixed JIT passes all three new cases.Regression_ro_2runner: 491 passed.jit-format: all nine Windows x64 configuration/project combinations passed.SuperPMI
All 10 matching Windows x64 collections: 2,764,370 contexts, zero failures or
misses for either JIT. 1,439 contexts changed; total code size grew by 1,851
bytes (+0.000156%). No throughput benchmark was run.
Resolves #135384
Note
This PR was created with GitHub Copilot.