Skip to content

Remove async method inlining restrictions in crossgen2#125472

Open
jtschuster wants to merge 2 commits intodotnet:mainfrom
jtschuster:InlineAsync
Open

Remove async method inlining restrictions in crossgen2#125472
jtschuster wants to merge 2 commits intodotnet:mainfrom
jtschuster:InlineAsync

Conversation

@jtschuster
Copy link
Member

Remove restrictions that prevented async methods from being inlined during ReadyToRun compilation.

All 69 async tests pass with both crossgen2 and composite R2R.

Output of the src/tests/async/execution-context/execution-context.cs was validated manually to ensure inlining is happening for async calls to methods without awaits. In Test(), these two calls were inlined as expected.

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static async Task ChangeThenThrowInlined()
{
s_local.Value = 123;
throw new Exception();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static async Task ChangeThenReturnInlined()
{
s_local.Value = 123;
}

Fixes #124665

Remove four restrictions that prevented async methods from being inlined
during ReadyToRun compilation:

1. CanInline() rejected IsAsyncThunk()/IsAsyncCall() callees
2. CrossModuleInlineableUncached() rejected async variants/thunks
3. reportInlining() threw when async methods were cross-module inlined
4. InliningInfoNode skipped recording inlining info for async thunks

All 69 async tests pass with both crossgen2 and composite R2R modes.

Fixes dotnet#124665

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 12, 2026 01:43
@jtschuster
Copy link
Member Author

/azp run runtime-coreclr crossgen2

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
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

Removes restrictions that prevented async methods from being inlined during ReadyToRun (crossgen2) compilation, fixing #124665.

Changes:

  • Removed four separate guards that blocked inlining of async methods (thunks, variants, calls) in R2R compilation.

Reviewed changes

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

File Description
CorInfoImpl.ReadyToRun.cs Removed exception throw for async method inlining
ReadyToRunCompilationModuleGroupBase.cs Removed cross-module inlining restriction for async methods
ReadyToRunCodegenCompilation.cs Removed CanInline restriction for async thunks/calls
InliningInfoNode.cs Removed skip of async thunks in inlining info emission

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Runtime-async methods are not inlined in crossgen2

2 participants