CodeGen: Copy-ctorm must obey the destination's alignment requirement

We would synthesize memcpy intrinsics when emitting calls to trivial C++
constructors but we wouldn't take into account the alignment of the
destination.

llvm-svn: 228061
This commit is contained in:
David Majnemer
2015-02-03 23:04:06 +00:00
parent 2a96704b33
commit fd1e739a44
3 changed files with 29 additions and 3 deletions

View File

@@ -1559,6 +1559,15 @@ public:
true);
}
void EmitAggregateCopyCtor(llvm::Value *DestPtr, llvm::Value *SrcPtr,
QualType DestTy, QualType SrcTy) {
CharUnits DestTypeAlign = getContext().getTypeAlignInChars(DestTy);
CharUnits SrcTypeAlign = getContext().getTypeAlignInChars(SrcTy);
EmitAggregateCopy(DestPtr, SrcPtr, SrcTy, /*IsVolatile=*/false,
std::min(DestTypeAlign, SrcTypeAlign),
/*IsAssignment=*/false);
}
/// EmitAggregateCopy - Emit an aggregate copy.
///
/// \param isVolatile - True iff either the source or the destination is