================
@@ -224,9 +225,26 @@ static LValueOrRValue 
emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Co
                                     AwaitKind Kind, AggValueSlot aggSlot,
                                     bool ignoreResult, bool forLValue) {
   auto *E = S.getCommonExpr();
+  auto &Builder = CGF.Builder;
 
-  auto CommonBinder =
-      CodeGenFunction::OpaqueValueMappingData::bind(CGF, S.getOpaqueValue(), 
E);
+  // S.getOperandOpaqueValue() may be null, in this case it maps to nothing.
+  std::optional<CodeGenFunction::OpaqueValueMapping> OperandMapping = 
std::nullopt;
+  auto CallOV = S.getOperandOpaqueValue();
+  if (CallOV) {
+    OperandMapping.emplace(CGF, CallOV);
+    LValue LV = CGF.getOrCreateOpaqueLValueMapping(CallOV);
+    llvm::Value *Value = LV.getPointer(CGF);
+    // for (auto *U : Value->users()) {
+    //   if (auto *Call = cast<llvm::CallBase>(U)) {
+    //     Call->dump();
+    //   }
+    // }
+    auto SafeElide = CGF.CGM.getIntrinsic(llvm::Intrinsic::coro_safe_elide);
+    if (cast<CallExpr>(CallOV->getSourceExpr())->isCoroutineInplaceTaskCall())
+      Builder.CreateCall(SafeElide, Value);
----------------
yuxuanchen1997 wrote:

TODO: don't use intrinsics. Use `llvm::Value`'s Metadata?

https://github.com/llvm/llvm-project/pull/94693
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to