Skip to content

JIT: Copy BBF_ASYNC_RESUMPTION when splitting edges in LSRA #115836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented May 21, 2025

Async resumption BBs are introduced late enough that we allow them to do some things that general BBs are not allowed to do. For example, they are allowed to jump into try regions at any point. This allowance is marked with the BBF_ASYNC_RESUMPTION flag. Propagate this flag from the source when edges are split by LSRA to allow the new block the same affordances.

Fix #115835

Async resumption BBs are introduced late enough that we allow them to do
some things that general BBs are not allowed to do. For example, they
are allowed to jump into try regions at any point. This allowance is
marked with the `BBF_ASYNC_RESUMPTION` flag. Propagate this flag from
the source when edges are split by LSRA to allow the new block the same
affordances.
@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 13:57
@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 May 21, 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 ensures that the BBF_ASYNC_RESUMPTION flag is correctly propagated when splitting edges in LSRA, thereby allowing async resumption basic blocks to properly jump into try/handler regions. Key changes include:

  • Replacing printf debug statements with JITDUMP in fgdiagnostic.cpp.
  • Copying the BBF_ASYNC_RESUMPTION flag into the new block when splitting edges in fgbasic.cpp.

Reviewed Changes

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

File Description
src/coreclr/jit/fgdiagnostic.cpp Replaced printf with JITDUMP for consistency in diagnostic logging.
src/coreclr/jit/fgbasic.cpp Propagates the BBF_ASYNC_RESUMPTION flag during edge splitting.
Comments suppressed due to low confidence (1)

src/coreclr/jit/fgbasic.cpp:4973

  • Verify that the CopyFlags call for BBF_ASYNC_RESUMPTION is additive and does not inadvertently override previously copied flags. If it overwrites flags, consider combining the flag copying into a single call to preserve all intended flag settings.
newBlock->CopyFlags(curr, BBF_ASYNC_RESUMPTION);

Copy link
Contributor

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

@jakobbotsch
Copy link
Member Author

PTAL @dotnet/jit-contrib

@jakobbotsch jakobbotsch requested a review from a team May 21, 2025 22:28
Copy link
Member

@EgorBo EgorBo left a comment

Choose a reason for hiding this comment

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

I presume nobody else can split blocks that late?

@jakobbotsch
Copy link
Member Author

I presume nobody else can split blocks that late?

I don't think so, but if so the fix here is inside fgSplitEdge, so they should also get it assuming they are using that helper.

@jakobbotsch jakobbotsch merged commit c9e01a5 into dotnet:main May 22, 2025
108 of 110 checks passed
@jakobbotsch jakobbotsch deleted the fix-115835 branch May 22, 2025 08:26
SimaTian pushed a commit that referenced this pull request May 27, 2025
Async resumption BBs are introduced late enough that we allow them to do
some things that general BBs are not allowed to do. For example, they
are allowed to jump into try regions at any point. This allowance is
marked with the `BBF_ASYNC_RESUMPTION` flag. Propagate this flag from
the source when edges are split by LSRA to allow the new block the same
affordances.
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: Assertion failed '!"Jump into middle of try region"' during 'Linear scan register alloc'
3 participants