================
@@ -901,6 +901,36 @@ void
CIRGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &args) {
assert(!cir::MissingFeatures::incrementProfileCounter());
assert(!cir::MissingFeatures::runCleanupsScope());
+ // For a memcpy-equivalent assignment operator, copy the whole object, then
+ // fall through to emit the trailing `return *this`.
+ if (assignOp->isMemcpyEquivalentSpecialMember(getContext())) {
+ CanQualType recordTy =
+ getContext().getCanonicalTagType(assignOp->getParent());
+ LValue dest = makeNaturalAlignAddrLValue(loadCXXThis(), recordTy);
+ mlir::Value srcPtr = builder.createLoad(getLoc(assignOp->getLocation()),
+ getAddrOfLocalVar(args.back()));
+ LValue src = makeNaturalAlignAddrLValue(srcPtr, recordTy);
+ emitAggregateAssign(dest, src, recordTy);
----------------
erichkeane wrote:
Hmm... this really seems wrong to me. I think we should just leave the copies
and count on some level of optimization to figure out "this is all the things,
just optimize them all".
CIR should better reflect the AST/semantics.
https://github.com/llvm/llvm-project/pull/198918
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits