-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: Model GS cookie check in LSRA #120192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Also switch the register used when generating the check if there is a tailcall in the block on x64. This allows us to enable fast tailcalls out of methods with GS cookie checks on x64.
/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress |
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this 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 enables fast tail calls from methods that require GS (Guard Stack) security cookie checks on x64 by modeling the GS cookie check in LSRA (Linear Scan Register Allocator) and adapting register selection for tail call scenarios. Previously, fast tail calls were disabled for methods with GS cookie checks on x64 due to compatibility requirements.
- Removes the restriction that prevented fast tail calls from methods with GS cookie checks on x64
- Models GS cookie checks in LSRA to properly handle register allocation conflicts
- Introduces dynamic register selection for GS cookie checks based on whether a tail call is present
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/tests/JIT/opt/Tailcall/TailcallVerifyWithPrefix.il | Removes test case Condition17 that is no longer needed |
src/coreclr/jit/targetriscv64.h | Replaces individual register definitions with register mask for GS cookie temps |
src/coreclr/jit/targetloongarch64.h | Replaces individual register definitions with register mask for GS cookie temps |
src/coreclr/jit/targetarm64.h | Replaces individual register definitions with register mask for GS cookie temps |
src/coreclr/jit/targetarm.h | Replaces individual register definitions with register mask for GS cookie temps |
src/coreclr/jit/morph.cpp | Removes x64-specific restriction preventing fast tail calls with GS cookie checks |
src/coreclr/jit/lsraxarch.cpp | Adds logic to exclude GS cookie temp registers from control expression candidates for fast tail calls |
src/coreclr/jit/lsrariscv64.cpp | Updates to use new centralized GS cookie temp register selection |
src/coreclr/jit/lsraloongarch64.cpp | Updates to use new centralized GS cookie temp register selection |
src/coreclr/jit/lsrabuild.cpp | Adds LSRA modeling for GS cookie checks by inserting register kills |
src/coreclr/jit/lsraarmarch.cpp | Updates to use new centralized GS cookie temp register selection |
src/coreclr/jit/lower.cpp | Removes assertion that prevented GS cookie checks in fast tail calls on x64 |
src/coreclr/jit/codegenxarch.cpp | Simplifies GS cookie check implementation and removes tail call specific logic |
src/coreclr/jit/codegenriscv64.cpp | Updates GS cookie check to use dynamic register selection |
src/coreclr/jit/codegenloongarch64.cpp | Updates GS cookie check to use dynamic register selection |
src/coreclr/jit/codegeninterface.h | Adds declaration for new genGetGSCookieTempRegs method |
src/coreclr/jit/codegencommon.cpp | Implements centralized logic for GS cookie temp register selection |
src/coreclr/jit/codegenarmarch.cpp | Updates GS cookie check to use dynamic register selection |
src/coreclr/jit/codegen.h | Updates genEmitGSCookieCheck method signature to use tailCall parameter |
} // end of method Condition17::.cctor | ||
|
||
} // end of class TailcallVerify.Condition17 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular test was relying on no tailcall to happen from method with unsafe local in it.
PTAL @dotnet/jit-contrib Diffs. Some minor size regressions because the proper encoding of the kill seems to perturb LSRA a little bit, making it pick some other registers with larger encoding. Rarely some improvements when we now tailcall out of some more methods. |
Also switch the register used when generating the check if there is a tailcall in the block on x64. This allows us to enable fast tailcalls out of methods with GS cookie checks on x64.
Fix #119949