r223563 - No memcpy for copy ctor with -fsanitize-address-field-padding=1
Kostya Serebryany
kcc at google.com
Fri Dec 5 17:23:09 PST 2014
Author: kcc
Date: Fri Dec 5 19:23:08 2014
New Revision: 223563
URL: http://llvm.org/viewvc/llvm-project?rev=223563&view=rev
Log:
No memcpy for copy ctor with -fsanitize-address-field-padding=1
Summary:
When -fsanitize-address-field-padding=1 is present
don't emit memcpy for copy constructor.
Thanks Nico for the extra test case.
Test Plan: regression tests
Reviewers: thakis, rsmith
Reviewed By: rsmith
Subscribers: rsmith, cfe-commits
Differential Revision: http://reviews.llvm.org/D6515
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGen/sanitize-address-field-padding.cpp
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=223563&r1=223562&r2=223563&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Dec 5 19:23:08 2014
@@ -1735,7 +1735,7 @@ void CodeGenFunction::EmitCXXConstructor
bool Delegating, llvm::Value *This,
const CXXConstructExpr *E) {
// If this is a trivial constructor, just emit what's needed.
- if (D->isTrivial()) {
+ if (D->isTrivial() && !D->getParent()->mayInsertExtraPadding()) {
if (E->getNumArgs() == 0) {
// Trivial default constructor, no codegen required.
assert(D->isDefaultConstructor() &&
@@ -1785,7 +1785,8 @@ void
CodeGenFunction::EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D,
llvm::Value *This, llvm::Value *Src,
const CXXConstructExpr *E) {
- if (D->isTrivial()) {
+ if (D->isTrivial() &&
+ !D->getParent()->mayInsertExtraPadding()) {
assert(E->getNumArgs() == 1 && "unexpected argcount for trivial ctor");
assert(D->isCopyOrMoveConstructor() &&
"trivial 1-arg ctor not a copy/move ctor");
Modified: cfe/trunk/test/CodeGen/sanitize-address-field-padding.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitize-address-field-padding.cpp?rev=223563&r1=223562&r2=223563&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/sanitize-address-field-padding.cpp (original)
+++ cfe/trunk/test/CodeGen/sanitize-address-field-padding.cpp Fri Dec 5 19:23:08 2014
@@ -229,6 +229,7 @@ struct ClassWithTrivialCopy {
void MakeTrivialCopy(ClassWithTrivialCopy *s1, ClassWithTrivialCopy *s2) {
*s1 = *s2;
+ ClassWithTrivialCopy s3(*s2);
}
// CHECK-LABEL: define void @_Z15MakeTrivialCopyP20ClassWithTrivialCopyS0_
More information about the cfe-commits
mailing list