Repository navigation
JIT: Stop the redundant zero-init scan at blocks with other predecessors - #135719
Merged
Merged
Conversation
optRemoveRedundantZeroInits follows unique BBJ_ALWAYS successors and assumes every path from the prolog went through the scanned blocks. A rejoin block can also be reached from a catch handler that writes the local (an address-exposed one, for example), so the explicit zero store there was wrongly removed. Stop the scan at blocks with more than one predecessor (including EH ones). libraries.pmi: +17 bytes in 2 methods. Fixes dotnet#134004 Co-authored-by: Copilot <[email protected]> Copilot-Session: 88502efb-96e2-4483-b698-59f5003a2e2c
|
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.
🟢 Approval recommended
The conservative guard fixes the demonstrated miscompilation with focused regression coverage; only a minor documentation update remains.
1 open finding
What changed in this PR
Fixes incorrect zero-store removal by stopping the JIT scan at control-flow rejoins.
Changes:
- Adds a multiple-predecessor guard.
- Adds a targeted EH regression test.
- Minor method documentation update remains requested.
| File | Description |
|---|---|
src/coreclr/jit/optimizer.cpp |
Stops zero-init analysis at blocks with multiple predecessors. |
src/tests/JIT/Regression_ro_2/Runtime_134004.cs |
Verifies catch-handler writes do not escape the subsequent zero assignment. |
🧠 Review effort: Balanced
This was referenced Oct 13, 2026
Closed
Member
Author
|
PTAL @dotnet/jit-contrib, trivial bug-fix |
JulieLeeMSFT
approved these changes
Oct 14, 2026
JulieLeeMSFT
left a comment
Member
There was a problem hiding this comment.
LGTM. It skips zero-init when a block is reachable from both normal flow and an EH handler.
tannergooding
approved these changes
Oct 14, 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.

optRemoveRedundantZeroInits follows unique BBJ_ALWAYS successors and assumes every path from the prolog went through the scanned blocks. A rejoin block can also be reached from a catch handler that writes the local (an address-exposed one, for example), so the explicit zero store there was wrongly removed. Stop the scan at blocks with more than one predecessor (including EH ones). libraries.pmi: +17 bytes in 2 methods.
Fixes #134004
A couple of regressions (required for correctness).