Skip to content

JIT: Centralize exception and write-barrier proofs in value numbering - #137045

Draft
NinoFloris wants to merge 4 commits into
dotnet:mainfrom
NinoFloris:jit/vn-dominated-exceptions
Draft

NinoFloris wants to merge 4 commits into
dotnet:mainfrom
NinoFloris:jit/vn-dominated-exceptions

Conversation

@NinoFloris

@NinoFloris NinoFloris commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Centralize exception and write-barrier proofs in value numbering so CSE and later phases can use them without rediscovering the same facts.

VN drops exception items already ruled out by dominating checks or fully covered joins, including exceptional entries. It publishes non-faulting and arithmetic properties during the numbering walk, and classifies write barriers after all reaching values have been numbered. This removes the duplicate VN-based non-null walk and write-barrier classification from global assertion propagation, and makes the information available earlier to RBO and hoisting.

CI results (negative is better):

Platform TP Code size PerfScore (geomean)
Linux x64 −0.233% −2,639 B −0.013%
Windows x64 −0.119% −58,988 B −0.015%
Linux arm64 −0.164% −239,088 B −0.018%
Windows arm64 −0.181% −248,680 B −0.019%
macOS arm64 −0.163% −14,744 B +0.031%
Linux arm −0.241% −623,900 B −0.012%
Windows x86 −0.323% −1,014,945 B −0.012%
Wasm −0.289% −2,455,267 B −0.098%

The awkward part is preserving contextual proofs when code moves. GTF_ORDER_DOMINATED marks the operation whose safety depends on an earlier check. It is local to that operation and is not propagated to parent nodes or folded into GTF_ORDER_SIDEEFF. Tree transformations inspect operands when they need a subtree summary, while LIR checks the operations directly. Hoisting receives scoped block anchors to check that the required facts still hold at the destination.

Focused regression tests cover exceptional entry into a finally, conditional hoisting, and write-barrier classification without losing stores, faults or live references.

@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 Nov 5, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 5, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 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.

@NinoFloris
NinoFloris force-pushed the jit/vn-dominated-exceptions branch 2 times, most recently from 52942ad to da6351b Compare November 5, 2026 23:31
@NinoFloris
NinoFloris force-pushed the jit/vn-dominated-exceptions branch 3 times, most recently from 3fae14d to 1a1445e Compare November 7, 2026 03:54
@NinoFloris
NinoFloris force-pushed the jit/vn-dominated-exceptions branch 5 times, most recently from 551e1ea to 0ffa0d4 Compare November 7, 2026 20:11
@NinoFloris NinoFloris changed the title Drop exception items a dominating node has already survived in value numbering JIT: Centralize exception and write-barrier proofs in value numbering Nov 7, 2026
@NinoFloris
NinoFloris force-pushed the jit/vn-dominated-exceptions branch 2 times, most recently from 9e5166c to 0bf9a73 Compare November 7, 2026 23:12
@NinoFloris
NinoFloris force-pushed the jit/vn-dominated-exceptions branch from 051cae4 to 88095c1 Compare November 8, 2026 13:28
@NinoFloris
NinoFloris force-pushed the jit/vn-dominated-exceptions branch from 5794b06 to bd19734 Compare November 9, 2026 21:42
@NinoFloris
NinoFloris force-pushed the jit/vn-dominated-exceptions branch from c702aac to f166c32 Compare November 10, 2026 16:02
Omit exception items that an earlier operation or covered join has already ruled out. Include exceptional entries in join coverage and index large survivor sets to bound lookup cost. Cover exceptional entry to an uncloned finally.
Publish non-faulting and arithmetic proofs during numbering and remove duplicate global assertion-propagation work. Distinguish owned and inherited dominated ordering, retain compact block anchors, and pass those records explicitly to hoisting.

Update tree and LIR motion, comparison folding, branch optimization and bounds-check coalescing together. Preserve dependencies through cloning and flag refreshes, and keep common flag-free paths cheap.

Keep a focused regression test for conditional hoisting.
Classify reference and block stores after all reaching values have been numbered, before CSE can hide their addresses or values. Use null-edge facts to remove unnecessary barriers and remove duplicate classification from assertion propagation.

Preserve destination fault behavior and test null edges and non-null stored values.
Keep the contextual marker on its operation without propagating it into ordinary ordering. Search subtrees where a transformation needs their ordering requirements, and use operation-local effects directly in LIR. Preserve argument evaluation constraints and ownership during long decomposition.

This branch has not been deployed

No deployments
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 community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant