Skip to content

JIT: fix liveness in throw helper blocks#124253

Merged
AndyAyersMS merged 1 commit intodotnet:mainfrom
AndyAyersMS:FixThrowHelperLiveness
Feb 11, 2026
Merged

JIT: fix liveness in throw helper blocks#124253
AndyAyersMS merged 1 commit intodotnet:mainfrom
AndyAyersMS:FixThrowHelperLiveness

Conversation

@AndyAyersMS
Copy link
Member

PR #123781 changed things so that throw helper blocks are now created just after lower. Because of this they no longer get the special liveness update for unreachable blocks.

Add this update in explicitly when the blocks are created.

Fixes #123929

PR dotnet#123781 changed things so that throw helper blocks are
now created just after lower. Because of this they no longer get
the special liveness update for unreachable blocks.

Add this update in explicitly when the blocks are created.

Fixes dotnet#123929
Copilot AI review requested due to automatic review settings February 11, 2026 01:14
@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 Feb 11, 2026
@dotnet-policy-service
Copy link
Contributor

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

@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Feb 11, 2026

@jakobbotsch PTAL
cc @dotnet/jit-contrib

This will have a handful of diffs

I will have two follow-on PRs once this merges:

  • only do this for BBJ_THROW_HELP blocks, not all unreachable blocks (should be no diff, small TP win)
  • we are emitting unneeded throw helpers for some GT_INDEX_ADDR nodes (will have diffs)

Also will run some other pipelines once the main part of CI is done.

Copy link
Contributor

Copilot AI left a 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 addresses a JIT liveness bug where throw-helper blocks can be created after the point where the “unreachable blocks” liveness fixup runs, leaving those blocks with incorrect bbLiveIn/bbLiveOut state and potentially causing downstream GC/liveness issues (as seen in #123929).

Changes:

  • Refactors the special throw-helper liveness update into a dedicated helper: Compiler::fgSetThrowHelpBlockLiveness.
  • Reuses that helper from Liveness<TLiveness>::DoLiveVarAnalysis() for blocks not present in the DFS tree.
  • Invokes the helper when a throw-helper block is created (fgCreateThrowHelperBlock) to ensure correct liveness even if the block is created late.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/coreclr/jit/liveness.cpp Extracts and centralizes throw-helper liveness fixup logic into fgSetThrowHelpBlockLiveness.
src/coreclr/jit/flowgraph.cpp Applies the throw-helper liveness fixup immediately when creating a throw-helper block.
src/coreclr/jit/compiler.h Declares the new fgSetThrowHelpBlockLiveness helper on Compiler.

@AndyAyersMS
Copy link
Member Author

/azp run runtime-coreclr r2r-extra, runtime-coreclr gcstress0x3-gcstress0xc

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I assume codegen is still implicitly referencing the throw helper blocks and that we thus cannot just run the liveness after they are created (i.e. it would require some special casing regardless of when we run it).

@AndyAyersMS
Copy link
Member Author

LGTM.

I assume codegen is still implicitly referencing the throw helper blocks and that we thus cannot just run the liveness after they are created (i.e. it would require some special casing regardless of when we run it).

Correct. We never update the flow graph to show the flow to these helpers. We would need to split blocks or create some new way to describe mid-block branches.

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.

Assert failure: !CREATE_CHECK_STRING(pMT && pMT->Validate())

3 participants