[clang] [llvm] [Clang][Coroutines] Introducing the `[[clang::coro_inplace_task]]` attribute (PR #94693)
Yuxuan Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 23:03:52 PDT 2024
================
@@ -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
More information about the llvm-commits
mailing list