From 188b4a405ad2076126ab165ba817038f354823e3 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 17 Feb 2026 10:45:17 +0100 Subject: [PATCH] JIT: Check for inline candidates in gtTreeContainsAsyncCall Inline candidates can later be substituted for the original call. That call may contain async calls, in which case the standard spilling behavior should kick. --- src/coreclr/jit/fgopt.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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;