Repository navigation
JIT: check LIR unused values in the post-phase checks - #132612
Merged
jakobbotsch merged 2 commits intoAug 24, 2026
Merged
Conversation
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
|
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 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_VALUESand plumbs it intofgDebugCheckLinksso post-phaseCheckLIRcan 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
CheckLIRcalls 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. |
Member
Author
|
PTAL @dotnet/jit-contrib |
jakobbotsch
commented
Aug 21, 2026
jakobbotsch
commented
Aug 21, 2026
Co-authored-by: Jakob Botsch Nielsen <[email protected]>
AndyAyersMS
approved these changes
Aug 21, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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.