Skip to content

JIT: check LIR unused values in the post-phase checks - #132612

Merged
jakobbotsch merged 2 commits into
dotnet:mainfrom
jakobbotsch:jit-lir-unused-values-check
Aug 24, 2026
Merged

jakobbotsch merged 2 commits into
dotnet:mainfrom
jakobbotsch:jit-lir-unused-values-check

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

CheckLIR's checkUnusedValues checking was only done by direct calls from Rationalizer, DecomposeLongs and Lowering, while the post-phase checks ran it without. Meanwhile codegen, fgUpdateFlowGraph and fgDebugCheckNodeLinks called CheckLIR again with checking that the post-phase checks already do.

Add CHECK_LIR_UNUSED_VALUES, enabled from rationalization until register allocation, and have fgDebugCheckLinks pass it on to CheckLIR. All six direct CheckLIR calls can then go away.

The check cannot stay on for LSRA since it inserts nodes without users to model register saves/restores.

Throughput on benchmarks.run for the checked JIT: -6.03% instructions retired, -5.59% wall clock.

CheckLIR's checkUnusedValues checking was only done by direct calls from
Rationalizer, DecomposeLongs and Lowering, while the post-phase checks ran it
without. Meanwhile codegen, fgUpdateFlowGraph and fgDebugCheckNodeLinks called
CheckLIR again with checking that the post-phase checks already do.

Add CHECK_LIR_UNUSED_VALUES, enabled from rationalization until register
allocation, and have fgDebugCheckLinks pass it on to CheckLIR. All six direct
CheckLIR calls can then go away.

The check cannot stay on for LSRA since it inserts nodes without users to model
register saves/restores.

Throughput on benchmarks.run for the checked JIT: -6.03% instructions retired,
-5.59% wall clock.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 064035bf-fb1f-450e-afd2-08a7700aa736
Copilot AI lite review requested due to automatic review settings August 21, 2026 12:30
@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 Aug 21, 2026
@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 refactors how LIR unused-value validation is enabled and executed in the JIT’s debug/post-phase checking pipeline, so that the “unused value” invariant is checked consistently after phases (where appropriate) rather than via scattered direct CheckLIR(..., true) call sites.

Changes:

  • Introduces PhaseChecks::CHECK_LIR_UNUSED_VALUES and plumbs it into fgDebugCheckLinks so post-phase CheckLIR can optionally validate unused-value marking.
  • Enables the unused-value check from just before rationalization through lowering, and disables it prior to LSRA (since LSRA may intentionally insert nodes without users).
  • Removes redundant direct CheckLIR calls from Rationalizer/Lowering/DecomposeLongs/CodeGen and some debug helpers, relying on post-phase checks instead.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/jit/compiler.h Adds a new PhaseChecks bit to represent enabling the LIR unused-value validation.
src/coreclr/jit/compiler.cpp Turns the new flag on before rationalization and off before LSRA.
src/coreclr/jit/fgdiagnostic.cpp Passes the new flag through fgDebugCheckLinks to CheckLIR.
src/coreclr/jit/rationalize.cpp Removes a direct CheckLIR(..., true) assert now covered by post-phase checks.
src/coreclr/jit/lower.cpp Removes a direct CheckLIR(..., true) assert now covered by post-phase checks.
src/coreclr/jit/decomposelongs.cpp Removes a direct CheckLIR(..., true) assert now covered by post-phase checks.
src/coreclr/jit/fgopt.cpp Removes a redundant debug-only CheckLIR sweep from fgUpdateFlowGraph.
src/coreclr/jit/codegenlinear.cpp Removes a redundant per-block CheckLIR assert in codegen.

@jakobbotsch

Copy link
Copy Markdown
Member Author

PTAL @dotnet/jit-contrib

@jakobbotsch
jakobbotsch requested a review from a team August 21, 2026 15:35
Comment thread src/coreclr/jit/compiler.cpp Resolved
Comment thread src/coreclr/jit/compiler.cpp Resolved
Co-authored-by: Jakob Botsch Nielsen <[email protected]>
Copilot AI review requested due to automatic review settings August 21, 2026 15:37

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@jakobbotsch
jakobbotsch merged commit 0b609ec into dotnet:main Aug 24, 2026
128 checks passed
@jakobbotsch
jakobbotsch deleted the jit-lir-unused-values-check branch August 24, 2026 11:46
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 25, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

3 participants