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

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 19:19:18 PDT 2024


================
@@ -5443,24 +5444,38 @@ RValue CodeGenFunction::EmitRValueForField(LValue LV,
 //===--------------------------------------------------------------------===//
 
 RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
-                                     ReturnValueSlot ReturnValue) {
+                                     ReturnValueSlot ReturnValue,
+                                     llvm::CallBase **CallOrInvoke) {
+  llvm::CallBase *CallOrInvokeStorage;
+  if (!CallOrInvoke) {
+    CallOrInvoke = &CallOrInvokeStorage;
+  }
+
+  auto AddCoroMustElideOnExit = llvm::make_scope_exit([&] {
+    if (E->isCoroMustElide()) {
+      auto *I = *CallOrInvoke;
+      if (I)
+        I->addFnAttr(llvm::Attribute::CoroMustElide);
----------------
ChuanqiXu9 wrote:

I agree the current style is more or less potential to scale. But I'd like to hear from @efriedma-quic since the patch changes a lot of CodeGen's functions signature and I want to know if he will be happy about this.

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


More information about the llvm-commits mailing list