[clang] [llvm] [Clang] C++20 Coroutines: Introduce Frontend Attribute [[clang::coro_await_elidable]] (PR #99282)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 28 01:47:34 PDT 2024


================
@@ -523,6 +523,12 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
     NormalCleanupDest = Address::invalid();
   }
 
+  if (getLangOpts().Coroutines && isCoroutine()) {
+    auto *Record = FnRetTy->getAsCXXRecordDecl();
+    if (Record && Record->hasAttr<CoroAwaitElidableAttr>())
+      CurFn->addFnAttr(llvm::Attribute::CoroGenNoallocRamp);
+  }
----------------
ChuanqiXu9 wrote:

I don't like this. It will add this attribute to all the coroutines with the attribute `[[[clang::coro_await_elidable]]](https://github.com/llvm/llvm-project/pull/99282/files#top)`. In practice it may always cause the CoroSplit pass to generate additional codes.

What I thought is, in CoroSplit pass, we can visit every user of the function, and if any user of the function is a call with the elide attribute, we can generate .noalloc variant for the current coroutine. 

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


More information about the cfe-commits mailing list