[clang] [llvm] [RFC][Coroutines] Implement HALO for coroutines that flow off final suspend (PR #185336)

Weibo He via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 9 19:18:01 PDT 2026


================
@@ -1163,10 +1162,9 @@ static void handleNoSuspendCoroutine(coro::Shape &Shape) {
   auto *CoroBegin = Shape.CoroBegin;
   switch (Shape.ABI) {
   case coro::ABI::Switch: {
-    auto SwitchId = Shape.getSwitchCoroId();
-    auto *AllocInst = SwitchId->getCoroAlloc();
-    coro::replaceCoroFree(SwitchId, /*Elide=*/AllocInst != nullptr);
----------------
NewSigma wrote:

I think there is no semantic change. Previously, we unconditionally lowered `coro.free`. Now, we lower it only for the cleanup function. Without `coro.dead`, the remaining `coro.free` intrinsics are lowered in CoroCleanup anyway, so this change essentially defers the lowering of `coro.free` to CoroCleanup. With `coro.dead`, we lower it to null only if resumers are inlined into the caller and elision is feasible. If resumers are not inlined, we lower `coro.free` inside them to FramePtr. This is safe because the coroutine cannot be destroyed twice.

https://github.com/llvm/llvm-project/pull/185336


More information about the cfe-commits mailing list