Summary: If we've added poisoned paddings to a type do not emit memcpy for operator=.
Test Plan: regression tests.
Reviewers: majnemer, rsmith
Reviewed By: rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6160
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221739
91177308-0d34-0410-b5e6-
96231b3b80d8
llvm::Value *This = LV.getAddress();
if ((MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) &&
- MD->isTrivial()) {
+ MD->isTrivial() && !MD->getParent()->mayInsertExtraPadding()) {
llvm::Value *Src = EmitLValue(E->getArg(1)).getAddress();
QualType Ty = E->getType();
EmitAggregateAssign(This, Src, Ty);
// WITH_CTOR_ALIASES-NOT: call void @_ZN15WithVirtualDtorD2Ev
// WITH_CTOR_ALIASES: call void @_ZN28InheritsFrom_WithVirtualDtorD2Ev
// WITH_CTOR_ALIASES: ret void
+
+// Make sure we don't emit memcpy for operator= if paddings are inserted.
+struct ClassWithTrivialCopy {
+ ClassWithTrivialCopy();
+ ~ClassWithTrivialCopy();
+ void *a;
+ private:
+ void *c;
+};
+
+void MakeTrivialCopy(ClassWithTrivialCopy *s1, ClassWithTrivialCopy *s2) {
+ *s1 = *s2;
+}
+
+// CHECK-LABEL: define void @_Z15MakeTrivialCopyP20ClassWithTrivialCopyS0_
+// CHECK-NOT: memcpy
+// CHECK: ret void