Skip to content

JIT: handle redefined enumerators in conditional escape analysis - #134658

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-134605-enumerator-redefinition
Sep 26, 2026
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-134605-enumerator-redefinition

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Fix conditional escape analysis when an enumerator local has multiple guarded definitions.

The RPO walk now rejects an earlier cloning candidate when a later definition may reach its guarded uses, while preserving dominated sequential redefinitions.

Validated with class and boxed-struct regressions, the disjoint zero-allocation case, Runtime_127075, and Runtime_131713.

Resolves #134605

Note

This pull request description was generated with GitHub Copilot.

Reject cloning when a later guarded definition may reach uses assigned to an earlier definition.

Fixes dotnet#134605

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ed9b45e3-0af5-4425-a189-1d0e0cbce294
Copilot AI lite review requested due to automatic review settings September 25, 2026 14:50
@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 Sep 25, 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.

Copilot review overview

🟡 Changes recommended

Later mapped definitions that cannot be stack allocated and missing test-runtime gating leave unresolved correctness and test reliability issues.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes JIT conditional escape analysis for redefined enumerator locals while adding class and boxed-struct regression coverage.

Changes:

  • Detects conflicting enumerator redefinitions during RPO analysis.
  • Rejects unsafe cloning candidates while preserving valid sequential cases.
  • Adds regression and allocation tests.
File Summary
src/​tests/​JIT/​opt/​ObjectStackAllocation/​Runtime_134605.csproj Configures the class-enumerator regression test.
src/​tests/​JIT/​opt/​ObjectStackAllocation/​Runtime_134605.cs Adds enumerator reassignment and allocation scenarios.
src/​tests/​JIT/​opt/​ObjectStackAllocation/​Runtime_134605_Struct.csproj Configures the boxed-struct variant.
src/​coreclr/​jit/​objectalloc.h Adds clone-candidate conflict state.
src/​coreclr/​jit/​objectalloc.cpp Detects and rejects unsafe enumerator redefinitions.

Comment thread src/coreclr/jit/objectalloc.cpp
@AndyAyersMS
AndyAyersMS requested a review from EgorBo September 25, 2026 15:26
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@EgorBo ptal
fyi @dotnet/jit-contrib

Tried to keep this one fairly surgical so it can be a backport. A more "robust" solution would be to run reaching defs or similar. But probably ends up a the same place, since we can't handle allocations in loops yet.

@AndyAyersMS
AndyAyersMS merged commit 754db27 into dotnet:main Sep 26, 2026
143 of 146 checks passed
@AndyAyersMS

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@AndyAyersMS

Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: enumerator reassignment inside loop ignored after conditional escape analysis

3 participants