================ @@ -1967,22 +2047,13 @@ splitCoroutine(Function &F, SmallVectorImpl<Function *> &Clones, for (DbgVariableRecord *DVR : DbgVariableRecords) coro::salvageDebugInfo(ArgToAllocaMap, *DVR, Shape.OptimizeFrame, false /*UseEntryValue*/); - return Shape; -} -/// Remove calls to llvm.coro.end in the original function. -static void removeCoroEndsFromRampFunction(const coro::Shape &Shape) { - if (Shape.ABI != coro::ABI::Switch) { - for (auto *End : Shape.CoroEnds) { - replaceCoroEnd(End, Shape, Shape.FramePtr, /*in resume*/ false, nullptr); - } - } else { - for (llvm::AnyCoroEndInst *End : Shape.CoroEnds) { - auto &Context = End->getContext(); - End->replaceAllUsesWith(ConstantInt::getFalse(Context)); - End->eraseFromParent(); - } + removeCoroEndsFromRampFunction(Shape); + + if (!isNoSuspendCoroutine && Shape.ABI == coro::ABI::Switch) { ---------------- vogelsgesang wrote:
Additionally, we should only create this `noalloc` variant, if the coroutines promise type itself is marked as "elidable". **Example** ``` struct [[coro_must_elide]] ElidedTask { ... } struct NonElidedTask { ... } ElidedTask foo(); NonElidedTask bar(); NonElidedTask foobar() { co_await foo(); co_await bar(); } ``` **Current behavior**: We create `foo.noalloc`, `bar.noalloc` and `foobar.alloc`. `foo.noalloc` gets actually called. However, `bar.noalloc` and `foobar.alloc` are dead code. The `.noalloc` variants will never be used, as the `NonElidedTask` is not marked with `[[coro_must_elide]]`. I think we should avoid generating this dead code https://github.com/llvm/llvm-project/pull/99283 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits