Repository navigation
Preserve exception order when head merging ordered statements - #137254
Merged
AndyAyersMS merged 1 commit intoNov 12, 2026
Merged
Conversation
Treat exceptions in the predecessor terminator as interference with an ordering-sensitive head. Invariant method-table loads can establish a null proof without GTF_GLOB_REF; moving the protected load ahead of the terminator can change which exception is thrown. Cover a division preceding a type test whose successors both read a field from the receiver. With a zero divisor and null receiver, the division must throw first.
|
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. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change to preserve exception ordering during JIT head merging.
No open issues 🎉
What changed in this PR
This PR addresses #137253 by preventing JIT head merging from moving ordering-sensitive statements ahead of a predecessor condition that can throw, preserving exception order.
Changes:
- Include
GTF_EXCEPTin the interference check for ordering-sensitive heads. - Add regression tests covering type checks, branch markers, and division-before-null exception ordering.
| File | Description |
|---|---|
src/tests/JIT/opt/HeadTailMerge/headmergeexception.cs |
Adds regression coverage for protected field reads and exception ordering. |
src/coreclr/jit/fgopt.cpp |
Blocks head movement across potentially throwing terminators. |
Review effort: Balanced
NinoFloris
marked this pull request as draft
November 11, 2026 12:40
NinoFloris
marked this pull request as ready for review
November 11, 2026 12:40
NinoFloris
marked this pull request as draft
November 11, 2026 19:20
NinoFloris
marked this pull request as ready for review
November 11, 2026 19:20
Member
|
/ba-g unrelated build failure |
Member
|
Thanks for spotting and fixing this! |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Treat exceptions in the predecessor terminator as interference with an ordering-sensitive head. Invariant method-table loads can establish a null proof without GTF_GLOB_REF; moving the protected load ahead of the terminator can change which exception is thrown.
Fixes #137253