Skip to content

Commit 2a0dfd7

Browse files
jtschusterCopilot
andcommitted
Remove async method inlining restrictions in crossgen2
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 <[email protected]>
1 parent c77d32c commit 2a0dfd7

4 files changed

Lines changed: 0 additions & 26 deletions

File tree

‎src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InliningInfoNode.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
7272
continue;
7373
}
7474
MethodDesc inliner = methodNode.Method;
75-
if (inliner.IsCompilerGeneratedILBodyForAsync())
76-
{
77-
// Async thunks are restricted from inlining. https://github.com/dotnet/runtime/issues/124665
78-
continue;
79-
}
8075
EcmaMethod inlinerDefinition = (EcmaMethod)inliner.GetPrimaryMethodDesc().GetTypicalMethodDefinition();
8176

8277
if (inlinerDefinition.IsNonVersionable())

‎src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ public bool CanInline(MethodDesc caller, MethodDesc callee)
109109
}
110110
}
111111

112-
// TODO: Enable async inlining. https://github.com/dotnet/runtime/issues/124665
113-
if (callee.IsAsyncThunk() || callee.IsAsyncCall())
114-
{
115-
return false;
116-
}
117-
118112
_nodeFactory.DetectGenericCycles(caller, callee);
119113

120114
return NodeFactory.CompilationModuleGroup.CanInline(caller, callee);

‎src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,6 @@ private bool CrossModuleInlineableInternal(MethodDesc method)
520520

521521
private bool CrossModuleInlineableUncached(MethodDesc method)
522522
{
523-
// Async thunks and variants cannot currently be inlined cross module
524-
if (method.IsAsyncVariant() || method.IsAsync || method.IsAsyncThunk())
525-
return false;
526-
527523
// Defined in corelib
528524
MetadataType owningMetadataType = method.OwningType.GetTypeDefinition() as MetadataType;
529525
if (owningMetadataType == null)

‎src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,17 +3306,6 @@ private void reportInliningDecision(CORINFO_METHOD_STRUCT_* inlinerHnd, CORINFO_
33063306

33073307
var typicalMethod = inlinee.GetTypicalMethodDefinition();
33083308

3309-
if ((typicalMethod.IsAsyncVariant() || typicalMethod.IsAsync || typicalMethod.IsCompilerGeneratedILBodyForAsync()) && !_compilation.CompilationModuleGroup.VersionsWithMethodBody(typicalMethod))
3310-
{
3311-
// TODO: fix this restriction in runtime async. https://github.com/dotnet/runtime/issues/124665
3312-
// Disable async methods in cross module inlines for now, we need to trigger the CheckILBodyFixupSignature in the right situations, and that hasn't been implemented
3313-
// yet. Currently, we'll correctly trigger the _ilBodiesNeeded logic below, but we also need to avoid triggering the ILBodyFixupSignature for the async thunks, but we ALSO need to make
3314-
// sure we generate the CheckILBodyFixupSignature for the actual runtime-async body in which case I think the typicalMethod will be an AsyncVariantMethod, which doesn't appear
3315-
// to be handled here. This check is here in the place where I believe we actually would behave incorrectly, but we also have a check in CrossModuleInlineable which disallows
3316-
// the cross module inline of async methods currently.
3317-
throw new Exception("Inlining async methods is not supported in ReadyToRun compilation.");
3318-
}
3319-
33203309
MethodIL methodIL = _compilation.GetMethodIL(typicalMethod);
33213310
if (methodIL is ILStubMethodIL ilStubMethodIL && ilStubMethodIL.StubILHasGeneratedTokens)
33223311
{

0 commit comments

Comments
 (0)