diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index 0ac687cd734153..547688a959c4da 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -5583,8 +5583,18 @@ bool Compiler::gtTreeContainsAsyncCall(GenTree* tree) return false; } - auto isAsyncCall = [](GenTree* tree) { - return tree->IsCall() && tree->AsCall()->IsAsync(); + auto isAsyncCall = [=](GenTree* tree) { + if (tree->IsCall() && tree->AsCall()->IsAsync()) + { + return true; + } + + if (tree->OperIs(GT_RET_EXPR) && gtTreeContainsAsyncCall(tree->AsRetExpr()->gtInlineCandidate)) + { + return true; + } + + return false; }; return gtFindNodeInTree(tree, isAsyncCall) != nullptr;