================ @@ -246,6 +290,44 @@ void AggExprEmitter::emitNullInitializationToLValue(mlir::Location loc, cgf.emitNullInitialization(loc, lv.getAddress(), lv.getType()); } +void AggExprEmitter::VisitCallExpr(const CallExpr *e) { + if (e->getCallReturnType(cgf.getContext())->isReferenceType()) { + cgf.cgm.errorNYI(e->getSourceRange(), "reference return type"); + return; + } + + withReturnValueSlot( + e, [&](ReturnValueSlot slot) { return cgf.emitCallExpr(e, slot); }); +} + +void AggExprEmitter::withReturnValueSlot( + const Expr *e, llvm::function_ref<RValue(ReturnValueSlot)> fn) { + QualType retTy = e->getType(); + + assert(!cir::MissingFeatures::aggValueSlotDestructedFlag()); + bool requiresDestruction = + retTy.isDestructedType() == QualType::DK_nontrivial_c_struct; + if (requiresDestruction) + cgf.cgm.errorNYI( + e->getSourceRange(), + "withReturnValueSlot: return value requiring destruction is NYI"); + + // If it makes no observable difference, save a memcpy + temporary. + // + // We need to always provide our own temporary if destruction is required. + // Otherwise, fn will emit its own, notice that it's "unused", and end its + // lifetime before we have the chance to emit a proper destructor call. + assert(!cir::MissingFeatures::aggValueSlotAlias()); ---------------- andykaylor wrote:
I'm adding a couple of these in https://github.com/llvm/llvm-project/pull/143932. We should revisit this after both PRs are merged. https://github.com/llvm/llvm-project/pull/143377 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits