[clang] [CIR] Upstream support for operator assign (PR #145979)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 27 06:32:00 PDT 2025
================
@@ -85,23 +85,24 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
return RValue::get(nullptr);
}
- bool trivialForCodegen =
- md->isTrivial() || (md->isDefaulted() && md->getParent()->isUnion());
- bool trivialAssignment =
- trivialForCodegen &&
- (md->isCopyAssignmentOperator() || md->isMoveAssignmentOperator()) &&
- !md->getParent()->mayInsertExtraPadding();
- (void)trivialAssignment;
+ // Note on trivial assignment
+ // --------------------------
+ // Classic codegen avoids generating the trivial copy/move assignment operator
+ // when it isn't necessary, choosing instead to just produce IR with an
+ // equivalent effect. We have chosen not to do that in CIR, instead emitting
+ // trivial copy/move assignment operators and allowing later transformations
+ // to optimize them away if appropriate.
----------------
erichkeane wrote:
I like this FWIW, and I think we should do MORE of this if we can get away with it. The 'premature optimizations' in the FE are only there because LLVM-IR isn't expressive enough to make it clear it is legal. CIR should make sure it is expressive enough for these situations.
https://github.com/llvm/llvm-project/pull/145979
More information about the cfe-commits
mailing list