diff options
author | Kostya Serebryany <kcc@google.com> | 2014-12-06 01:23:08 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2014-12-06 01:23:08 +0000 |
commit | 597dcc7a8deb329037175f79bd0bd406a2aa880b (patch) | |
tree | 434cc54dc4f703875e2b20b6e09f094ce5eb0933 /clang/lib/CodeGen/CGClass.cpp | |
parent | b36ba28d60b2e06c427f34bc7e0d0498707aff74 (diff) | |
download | llvm-597dcc7a8deb329037175f79bd0bd406a2aa880b.zip llvm-597dcc7a8deb329037175f79bd0bd406a2aa880b.tar.gz llvm-597dcc7a8deb329037175f79bd0bd406a2aa880b.tar.bz2 |
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
llvm-svn: 223563
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index dd19471..e2af17c 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -1735,7 +1735,7 @@ void CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D, 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"); |