JIT: don't merge assertions from orphaned pred blocks - #131471
Open
AndyAyersMS wants to merge 1 commit into
Open
JIT: don't merge assertions from orphaned pred blocks#131471AndyAyersMS wants to merge 1 commit into
AndyAyersMS wants to merge 1 commit into
Conversation
RBO's jump threading can leave a block with bbPreds == nullptr without deleting it, and phi-arg gtPredBB references to that block are never rewritten. RangeCheck::MergeAssertion read those edge assertions unconditionally, producing wrong-code when the stale edge's outgoing assertions don't hold on any live path into the phi's block. Guard the phi-arg case with the same isUnreachableBlock check that optVisitReachingAssertions uses. Fixes dotnet#131404, dotnet#131436. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
@EgorBo PTAL A couple of SPMI diffs More notes here: #131436 (comment) |
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 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.
Pull request overview
This PR hardens JIT range analysis against unreachable/orphaned predecessor blocks by skipping edge-assertion merges for GT_PHI_ARG inputs when the phi’s recorded predecessor block is effectively unreachable (no normal predecessors, not the entry block, and not a handler-begin).
Changes:
- Add an unreachable/orphaned predecessor guard in
RangeCheck::MergeAssertionfor theGT_PHI_ARGpath. - Avoid merging edge assertions from such unreachable predecessor blocks, aligning behavior with the existing guard in
Compiler::optVisitReachingAssertions.
EgorBo
approved these changes
Jul 28, 2026
Member
Author
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.
RBO's jump threading can leave a block with bbPreds == nullptr without deleting it, and phi-arg gtPredBB references to that block are never rewritten. RangeCheck::MergeAssertion read those edge assertions unconditionally, producing wrong-code when the stale edge's outgoing assertions don't hold on any live path into the phi's block.
Guard the phi-arg case with the same isUnreachableBlock check that optVisitReachingAssertions uses.
Fixes #131404, #131436.