diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs index 787abe81061470..6c82c6ae40fc2a 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs @@ -58,7 +58,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) if (factory.OptimizationFlags.StripILBodies && factory.OptimizationFlags.CompiledMethodDefs.Contains(_method) - && !MayNeedILAtRuntime(_method)) + && !MayNeedILAtRuntime(factory, _method)) { return new ObjectData(s_minimalILBody, Array.Empty(), 4, new ISymbolDefinitionNode[] { this }); } @@ -72,7 +72,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) return new ObjectData(bodyBytes, Array.Empty(), 4, new ISymbolDefinitionNode[] { this }); } - private static bool MayNeedILAtRuntime(MethodDesc method) + private static bool MayNeedILAtRuntime(NodeFactory factory, MethodDesc method) { if (method.HasInstantiation || method.OwningType.HasInstantiation) { @@ -80,10 +80,19 @@ private static bool MayNeedILAtRuntime(MethodDesc method) return true; } - if (method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask() && !method.IsAsync) + if (method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask()) { - // IL may be needed for async version of non-async Task-returning method - return true; + if (!method.IsAsync) + { + // IL may be needed for async version of non-async Task-returning method + return true; + } + + MethodDesc asyncVariant = method.GetAsyncVariant().GetTypicalMethodDefinition(); + if (!factory.OptimizationFlags.CompiledMethodDefs.Contains(asyncVariant)) + { + return true; + } } return false; diff --git a/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj b/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj index 81e5ede74483d1..058bf79a8a454c 100644 --- a/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj +++ b/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj @@ -2,6 +2,7 @@ true + false $(NetCoreAppCurrent);$(NetFrameworkCurrent) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj index 7e769bdb467224..f9639376b4728c 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj @@ -3,6 +3,7 @@ true true true + false $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser diff --git a/src/tests/JIT/Regression/Regression_o_2.csproj b/src/tests/JIT/Regression/Regression_o_2.csproj index 9728cf50929a5d..281a19fe23f1fc 100644 --- a/src/tests/JIT/Regression/Regression_o_2.csproj +++ b/src/tests/JIT/Regression/Regression_o_2.csproj @@ -2,6 +2,7 @@ True True + false