Skip to content

Conversation

AndyAyersMS
Copy link
Member

Enable conditional escape analysis if the allocation was at one time guarded by a GDV, even if that GDV gets resolved by the new GDV cleanup pass that runs before escape analysis.

Fixes #117204.

Enable conditional escape analysis if the allocation was at one time guarded by a GDV,
even if that GDV gets resolved by the new GDV cleanup pass that runs before escape analysis.

Fixes dotnet#117204.
@Copilot Copilot AI review requested due to automatic review settings July 1, 2025 23:08
@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 Jul 1, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR relaxes the constraint for conditional escape analysis by tracking allocations that were once guarded by a GDV even after the guard has been cleaned up.

  • Removed the m_domBlock member and its assignments from CloneInfo
  • Eliminated the IsGuarded check so all GT_ALLOCOBJ allocations are now unconditionally tracked
  • Cleaned up related debug dumps and comments

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/coreclr/jit/objectalloc.h Removed m_domBlock field from CloneInfo
src/coreclr/jit/objectalloc.cpp Removed guard check (IsGuarded), always track allocations, and cleaned up info->m_domBlock assignment and debug dump
Comments suppressed due to low confidence (3)

src/coreclr/jit/objectalloc.cpp:3320

  • [nitpick] The comment still references GDV but the logic now tracks all allocations unconditionally. Consider updating it to reflect that allocations are always tracked regardless of any guard.
        // This may be an allocation of a concrete class under GDV.

src/coreclr/jit/objectalloc.cpp:3317

  • The change relaxes escape analysis constraints but introduces new behavior paths. Please add or update unit tests to cover allocations that were previously skipped when the guard was removed.
    //

src/coreclr/jit/objectalloc.cpp:3320

  • [nitpick] By removing the guard check, every GT_ALLOCOBJ goes through the cloning logic, which could increase compile-time work. Consider benchmarking or adding heuristics to avoid unintended performance regressions.
        // This may be an allocation of a concrete class under GDV.

Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@AndyAyersMS
Copy link
Member Author

PTAL @dotnet/jit-contrib

Because of the way Enumerator ALLOCOBJ flagging works we don't need to verify the allocation is currently guarded by a GDV; it only gets flagged when (in earlier phases) it was guarded.

@AndyAyersMS AndyAyersMS merged commit 8e2a1d5 into dotnet:main Jul 2, 2025
118 of 127 checks passed
AndyAyersMS added a commit to AndyAyersMS/runtime that referenced this pull request Jul 4, 2025
Proceed with CEA cloning even when the allocation site dominates the assignment
to the enumerator var. The cloning will be a bit wasteful as the original code will
become unreachable, but the code is set up to specialize the clone and so this is
the less risky fix.

Also restore recognition of `IEnumerable<T>.GetEnumerator` as this gives a useful
inlining boost in some cases.

Fixes dotnet#117204 cases that were not fixed by dotnet#117222.
AndyAyersMS added a commit that referenced this pull request Jul 7, 2025
Proceed with CEA cloning even when the allocation site dominates the assignment
to the enumerator var. The cloning will be a bit wasteful as the original code will
become unreachable, but the code is set up to specialize the clone and so this is
the less risky fix.

Also restore recognition of `IEnumerable<T>.GetEnumerator` as this gives a useful
inlining boost in some cases.

Fixes #117204 cases that were not fixed by #117222.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 2025
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.

[Perf] Linux/x64: 8 Regressions on 6/25/2025 10:56:24 PM +00:00
2 participants