[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
Tue Aug 6 23:58:40 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:

It looks like all the changes in CodeGen are served for this. And I am a little concerned about if it is worthy to do such a big change for this. @efriedma-quic could you take a look here?

And I am wondering if all of the Emit*CallExpr function will be converged to one or a few fundamental functions to emit the CallInst like `EmitCall` then we can do our job there.

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


More information about the cfe-commits mailing list