Skip to content

JIT: Optimize always suspending helpers - #130493

Merged
jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:fix-128324
Jul 24, 2026
Merged

JIT: Optimize always suspending helpers#130493
jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:fix-128324

Conversation

@jakobbotsch

@jakobbotsch jakobbotsch commented Jul 10, 2026

Copy link
Copy Markdown
Member

Several async helpers are known to always suspend. We can skip the "returned a continuation?" check for those.

Fix #128324

Several async helpers are known to always suspend. We can skip the
"returned a continuation" check for those.
Copilot AI review requested due to automatic review settings July 10, 2026 15:01
@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 10, 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.

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.

Pull request overview

This PR teaches the CoreCLR JIT’s runtime-async transformation to treat certain async helper calls as always suspending, allowing it to skip generating the “did the call return a continuation?” null check and instead unconditionally branch to the suspension path. To enable this, the relevant helpers are marked [Intrinsic] and recognized by lookupNamedIntrinsic, and a new AsyncCallInfo::AlwaysSuspends bit flows from import to async transformation.

Changes:

  • Mark AsyncHelpers.AwaitAwaiter / UnsafeAwaitAwaiter and CoreCLR’s Suspend* / TransparentSuspend* helpers as [Intrinsic] so the JIT can identify them reliably.
  • Add new named intrinsics for these helpers and plumb NamedIntrinsic into impSetupAsyncCall to set AsyncCallInfo.AlwaysSuspends.
  • Update AsyncTransformation::CreateCheckAndSuspendAfterCall to omit the null-continuation check when AlwaysSuspends is set.

Reviewed changes

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

Show a summary per file
File Description
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs Marks AwaitAwaiter / UnsafeAwaitAwaiter as [Intrinsic] to enable JIT recognition.
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs Marks Suspend* / TransparentSuspend* helpers as [Intrinsic] for JIT recognition.
src/coreclr/jit/namedintrinsiclist.h Adds new NamedIntrinsic IDs for always-suspending async helpers.
src/coreclr/jit/importercalls.cpp Recognizes new helper intrinsics and plumbs NamedIntrinsic into async-call setup to set AlwaysSuspends.
src/coreclr/jit/gentree.h Extends AsyncCallInfo with AlwaysSuspends.
src/coreclr/jit/compiler.h Updates impSetupAsyncCall signature to accept the callee NamedIntrinsic.
src/coreclr/jit/async.cpp Skips null-continuation check and changes CFG wiring for AlwaysSuspends calls.

Comment thread src/coreclr/jit/async.cpp
Comment thread src/coreclr/jit/async.cpp
@jakobbotsch
jakobbotsch marked this pull request as ready for review July 14, 2026 08:56
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@jakobbotsch

Copy link
Copy Markdown
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

Sadly cannot see diffs here because it requires the APIs to be marked Intrinsic.

@jakobbotsch
jakobbotsch requested a review from AndyAyersMS July 14, 2026 15:00
@github-actions

This comment was marked as spam.

github-actions[bot]

This comment was marked as spam.

@jakobbotsch

Copy link
Copy Markdown
Member Author

/ba-g Failure is #128907

@jakobbotsch
jakobbotsch merged commit fb070c0 into dotnet:main Jul 24, 2026
178 of 181 checks passed
@jakobbotsch
jakobbotsch deleted the fix-128324 branch July 24, 2026 15:49
hez2010 pushed a commit to hez2010/runtime that referenced this pull request Jul 26, 2026
Several async helpers are known to always suspend. We can skip the
"returned a continuation?" check for those.
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 26, 2026
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: optimize always-suspending helpers

3 participants