From 0fa74e6c3ba88dc8540c6ea9e95719e014fc15ff Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 5 Jan 2026 12:44:54 +0100 Subject: [PATCH] JIT: Look harder for async calls in ASYNC_CONTINUATION lowering When the `AsyncHelpers.AsyncCallContinuation` intrinsic is used explicitly the introduced `ASYNC_CONTINUATION` node needs to appear right after the async call in linear order. That would usually be the case, but in some cases we can have a `stloc` for the call result that turns into an intervening helper call. Fix by trying harder to locate the previous async call and allow skipping over other non-async calls. --- src/coreclr/jit/lower.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 118d7b75b320e1..84772bf1aeaf75 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -5925,9 +5925,8 @@ GenTree* Lowering::LowerAsyncContinuation(GenTree* asyncCont) node = node->gtPrev; noway_assert((node != nullptr) && "Ran out of nodes while looking for call before async continuation"); - if (node->IsCall()) + if (node->IsCall() && node->AsCall()->IsAsync()) { - assert(node->AsCall()->IsAsync()); BlockRange().Remove(asyncCont); BlockRange().InsertAfter(node, asyncCont); break;