Skip to content

JIT: don't merge assertions from orphaned pred blocks - #131471

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:andya/jit-mergeassertion-orphan-pred
Open

JIT: don't merge assertions from orphaned pred blocks#131471
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:andya/jit-mergeassertion-orphan-pred

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

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.

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>
Copilot AI review requested due to automatic review settings July 28, 2026 14:55
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 28, 2026
@AndyAyersMS

AndyAyersMS commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

@EgorBo PTAL
fyi @dotnet/jit-contrib

A couple of SPMI diffs

More notes here: #131436 (comment)

@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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::MergeAssertion for the GT_PHI_ARG path.
  • Avoid merging edge assertions from such unreachable predecessor blocks, aligning behavior with the existing guard in Compiler::optVisitReachingAssertions.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

diffs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failure: System.Text.Json.Tests.Utf8JsonWriterTests.WriteStringValueSegment_Utf8_Split8CodePointsBasic

3 participants