Repository navigation
JIT: Treat stores to EH-live locals as visible when hoisting - #135850
Merged
Merged
Conversation
`HoistVisitor` considered a local store globally visible only if the local was address-exposed, so `m_canHoistSideEffects` stayed true after `state = i + 1` and a later throwing `a / b` was hoisted into the preheader. But `state` is live into the catch handler, which then observed the old value. Fix: also treat stores to locals that are live in/out of a handler (or untracked) as visible when the block may throw into a handler. No asm diffs in libraries.pmi. Fixes dotnet#134938 Co-authored-by: Copilot <[email protected]> Copilot-Session: ef747772-3030-470e-b839-f9a4fc116717
|
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.
🔵 Needs a closer look
Exception-sensitive JIT code motion needs maintainer confirmation and checked-runtime regression validation, which was not performed in this review.
0 open findings
What changed in this PR
Fixes loop hoisting that could move a throwing expression ahead of a local store observable by an exception handler, causing the handler to see stale state.
Changes:
- Treats handler-live or untracked local stores as visible when the block has potential exception-handler successors.
- Adds a regression test verifying that the catch handler observes the updated local value.
| File | Description |
|---|---|
| src/tests/JIT/Regression_ro_2/Runtime_134938.cs | Tests local-state visibility after division throws. |
| src/coreclr/jit/optimizer.cpp | Extends store-visibility checks used by loop hoisting. |
🧠 Review effort: Balanced
This was referenced Oct 15, 2026
Open
Closed
Member
Author
|
PTAL @dotnet/jit-contrib, trivial change, a few diffs |
This was referenced Oct 15, 2026
adamperlin
approved these changes
Oct 16, 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.
HoistVisitorconsidered a local store globally visible only if the local was address-exposed, som_canHoistSideEffectsstayed true afterstate = i + 1and a later throwinga / bwas hoisted into the preheader. Butstateis live into the catch handler, which then observed the old value.Fix: also treat stores to locals that are live in/out of a handler (or untracked) as visible when the block may throw into a handler. No asm diffs in libraries.pmi.
Fixes #134938
A few diffs