[llvm] [Coroutines] Implement elision for noop coroutines (PR #174353)

Weibo He via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 18 18:30:57 PST 2026


NewSigma wrote:

> The most common use case for this is a simple await_suspend like this:

Thanks for the feedback. The pattern is slightly more complex. Noting that it resumes coroutine immediately after the phi node, we can hoist these resume calls and elide noop coroutine in `elideNoopCoro`.

> Perhaps what I'm asking for could be generalized as "inlining indirect calls/jumps when the target is statically known".

I think we have those optimizations in CoroElide, but they sometimes fail. Improvements are on the plan.

> I was using libstdc++ which does not emit this intrinsic. I expect the majority of users are still working this way.

I would expect libstdc++ support it. You can emit the intrinsic with __builtin_coro_noop() for now.

> in my code it's a PHINode:

It looks different. What is going on between the phi node and the resume call? There is nothing we can do if the logic is complex.

If there are no objections, I propose to leave the issue open and land this. A fixing will be submitted in another pr.


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


More information about the llvm-commits mailing list