Skip to content

JIT: Share suspension epilogs in async transformation#125174

Draft
jakobbotsch wants to merge 4 commits intodotnet:mainfrom
jakobbotsch:shared-async-epilogs
Draft

JIT: Share suspension epilogs in async transformation#125174
jakobbotsch wants to merge 4 commits intodotnet:mainfrom
jakobbotsch:shared-async-epilogs

Conversation

@jakobbotsch
Copy link
Copy Markdown
Member

@jakobbotsch jakobbotsch commented Mar 4, 2026

If we have more than one await, then create a shared GT_RETURN_SUSPEND block and use that for suspension always.

Pretty modest R2R size diffs for x64.

R2R size diffs x64
Assembly                                               R2R base     R2R diff  R2R Delta    R2R %
--------                                            -----------     --------  ---------    -----
System.IO.Compression.dll                               458,752      454,656    -4.0 KB   -0.89%
System.Linq.AsyncEnumerable.dll                       1,220,608    1,216,512    -4.0 KB   -0.34%
System.Net.Http.dll                                   1,622,016    1,617,920    -4.0 KB   -0.25%
System.Private.Xml.dll                                7,548,928    7,544,832    -4.0 KB   -0.05%

Detailed asp.net+runtimeasync crossgen2 diffs:
https://gist.github.com/jakobbotsch/ab57d97f2ea63f30ada41cb57713c779

Copilot AI review requested due to automatic review settings March 4, 2026 13:12
@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 Mar 4, 2026
@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.

Copy link
Copy Markdown
Contributor

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 changes the CoreCLR JIT async transformation to share a single GT_RETURN_SUSPEND “shared return” block when there are multiple awaits, so multiple suspension points can branch to one epilog.

Changes:

  • Refactors await discovery into FindAwaits(...), tracking normal vs tail-awaits and total await counts.
  • Transforms tail awaits in a first pass (TransformTailAwaits(...)) and re-scans when needed.
  • Introduces CreateSharedReturnBB() to create a shared GT_RETURN_SUSPEND block when #awaits > 1.

Reviewed changes

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

File Description
src/coreclr/jit/async.h Adds declarations for await discovery, tail-await batch transform, and shared return block creation.
src/coreclr/jit/async.cpp Implements the refactor and shared return block creation, and updates tail-await suspension to use m_sharedReturnBB.

Copilot AI review requested due to automatic review settings March 4, 2026 13:24
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

@jakobbotsch
Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr superpmi-diffs

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

If we have more than one await, then create a shared `GT_RETURN_SUSPEND`
block and use that for suspension always.
@jakobbotsch jakobbotsch force-pushed the shared-async-epilogs branch from 899702f to b5f17f9 Compare March 23, 2026 13:39
Copilot AI review requested due to automatic review settings March 23, 2026 13:39
Copy link
Copy Markdown
Contributor

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

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

Copilot AI review requested due to automatic review settings March 24, 2026 11:45
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

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.

2 participants