[clang] [CIR] Inline trivial copy/move assignment at call sites (PR #198918)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 22 13:58:43 PDT 2026
================
@@ -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:
I think we should do both. Lets leave Unions NYI here, and open a separate PR to fix the union case in the AST. I think there is value to fixing this 'fixme', but it needs to be done with a much wider audience than this patch.
https://github.com/llvm/llvm-project/pull/198918
More information about the cfe-commits
mailing list