[libcxx-commits] [clang] [libcxx] Elide suspension points via [[clang::coro_await_suspend_destroy]] (PR #152623)

Chuanqi Xu via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 11 20:55:18 PDT 2025


ChuanqiXu9 wrote:

> My current IR test verifies that there's no heap alloc across a few examples. Were you thinking of a different kind of test? Can you be very specific since I'm totally new to LLVM?

I mean to add a test for https://github.com/llvm/llvm-project/issues/148380 to show we can cover that in certain cases. Specifically, you can have a test on the IR to show it is devirtualized.

> I don't know when I'll next be able to make time to work on this, but if I do, my next target would be std::suspend_never. I hope this one could be done without an attribute, though. Do you have other use-cases in mind?

e.g., add an attribute to ask the compiler don't generate await.suspend intrinsics then the compiler may have optimized the await_suspend call better by inlining. The cost is the risk if the code resume or destroy the current coroutine during await_suspend somehow. But the programmer should be able to know that.

The core idea is to avoid generating  await.suspend intrinsics conditionally. I am open to the conditions.

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


More information about the libcxx-commits mailing list