Skip to content

JIT: Stop the redundant zero-init scan at blocks with other predecessors - #135719

Merged
EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:fix-jit-134004
Oct 14, 2026
Merged

EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:fix-jit-134004

Conversation

@EgorBo

@EgorBo EgorBo commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

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).

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
@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 Oct 13, 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.

🟢 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

Comment thread src/coreclr/jit/optimizer.cpp Resolved
@EgorBo

EgorBo commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

PTAL @dotnet/jit-contrib, trivial bug-fix

@EgorBo
EgorBo requested a review from a team October 14, 2026 02:04

@JulieLeeMSFT JulieLeeMSFT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It skips zero-init when a block is reachable from both normal flow and an EH handler.

@EgorBo
EgorBo merged commit 1f50563 into dotnet:main Oct 14, 2026
136 of 138 checks passed
@EgorBo
EgorBo deleted the fix-jit-134004 branch October 14, 2026 21:45
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 19, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 19, 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.

JIT: (bug) optRemoveRedundantZeroInits removes a required zero store after a catch-handler write

4 participants