-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: Improve precision of tailcall "has GC safe point" assert #123489
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
Since tailcalls can form tight loops that do not allow for return address hijacking we take care to introduce GC safe points in those scenarios. We had an assert for this, but the assert can result in false positives. In the test case we have two tailcalls via JIT helpers, both in blocks with GC safe points in them. Later tail merging merges them into a new block without a GC safe point, and that makes the assert in lowering hit, despite the fact that both preds are GC safe points. Fix the assert by introducing a graph walk. Fast tailcalls can use the same assert now, fixing a TODO-Cleanup at the same time.
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib |
|
/azp run runtime-coreclr jitstress |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
cc @dotnet/jit-contrib PTAL @EgorBo |
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 updates the JIT’s debug-only tailcall “GC safe point” assertion logic to avoid false negatives caused by tail-merge creating a new block without a GC safe point, despite all predecessors being GC safe points.
Changes:
- Replace the old tailcall-via-helper “current block OR entry block is a GC safe point” assert with a reachability-based check.
- Apply the same reachability-based assert to fast tailcalls, removing the prior TODO-based workaround.
- Introduce a DEBUG-only CFG walk helper (
IsBlockReachableWithoutGCSafePoint) used by these asserts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/lower.h | Declares a new helper used by debug asserts to validate GC-safe-point reachability. |
| src/coreclr/jit/lower.cpp | Updates tailcall asserts and adds a DEBUG-only CFG walk to avoid false negatives after tail merging. |
|
/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Since tailcalls can form tight loops that do not allow for return address hijacking we take care to introduce GC safe points in those scenarios. We had an assert for this, but the assert can result in false negatives.
In the test case we have two tailcalls via JIT helpers, both in blocks with GC safe points in them. Later tail merging merges them into a new block without a GC safe point, and that makes the assert in lowering hit, despite the fact that both preds are GC safe points.
Fix the assert by introducing a graph walk. Fast tailcalls can use the same assert now, fixing a TODO-Cleanup at the same time.
Fix #122481