JIT: Switch GS cookie check temp reg to use r10 for tailcalls#120941
Merged
jakobbotsch merged 1 commit intodotnet:mainfrom Oct 22, 2025
Merged
JIT: Switch GS cookie check temp reg to use r10 for tailcalls#120941jakobbotsch merged 1 commit intodotnet:mainfrom
jakobbotsch merged 1 commit intodotnet:mainfrom
Conversation
rax was used before, but rax is used as an argument for the indirection cell for R2R tailcalls. r10 has a use for some pinvokes, but we do not tailcall for these.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a register conflict issue in JIT compilation where the GS cookie check was using the rax register for tailcalls, but rax is also needed for R2R (Ready-to-Run) indirection cells during tailcalls. The fix changes the temporary register used for GS cookie checks in tailcall scenarios from rax to r10 on x64 platforms.
Key changes:
- Modified
genGetGSCookieTempRegsto return r10 instead of rax for x64 tailcalls - Added an assertion in
AddFinalArgsAndDetermineABIInfoto verify that PInvoke functions with non-standard args are not tail-called
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/codegencommon.cpp | Changes GS cookie temp register from rax to r10 for x64 tailcalls and refactors conditional compilation directives |
| src/coreclr/jit/morph.cpp | Adds assertion and comment documenting that PInvoke functions are not tail-called, preventing conflict with r11 |
Member
Author
|
PTAL @dotnet/jit-contrib, another one of these, this time around the change that enabled tailcalls for functions with GS cookie checks on x64. |
jakobbotsch
commented
Oct 22, 2025
AndyAyersMS
approved these changes
Oct 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rax was used before, but rax is used as an argument for the indirection cell for R2R tailcalls. r10 has a use for some pinvokes, but we do not tailcall for these.
Fix #120780