diff options
| author | Tom Stellard <thomas.stellard@amd.com> | 2014-04-11 19:36:51 +0000 |
|---|---|---|
| committer | Tom Stellard <thomas.stellard@amd.com> | 2014-04-11 19:36:51 +0000 |
| commit | e057ce0c13e8be4d5f59753a9e22d2f8f85d1927 (patch) | |
| tree | 82fab9f5d9797b7d216229bb6633c5bf57515bba | |
| parent | 73350399b163688a9384b3c64eca742625ab9e31 (diff) | |
| download | clang-e057ce0c13e8be4d5f59753a9e22d2f8f85d1927.tar.gz clang-e057ce0c13e8be4d5f59753a9e22d2f8f85d1927.tar.bz2 clang-e057ce0c13e8be4d5f59753a9e22d2f8f85d1927.tar.xz | |
Merging r203007:
------------------------------------------------------------------------
r203007 | rafael.espindola | 2014-03-05 16:04:41 -0500 (Wed, 05 Mar 2014) | 4 lines
Don't produce an alias between destructors with different calling conventions.
Fixes pr19007.
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@206059 91177308-0d34-0410-b5e6-96231b3b80d8
| -rw-r--r-- | lib/CodeGen/CGCXX.cpp | 6 | ||||
| -rw-r--r-- | test/CodeGenCXX/ctor-dtor-alias.cpp | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index cfb2d6291b..2f8a17afbc 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -92,7 +92,13 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) { if (!ClassLayout.getBaseClassOffset(UniqueBase).isZero()) return true; + // Give up if the calling conventions don't match. We could update the call, + // but it is probably not worth it. const CXXDestructorDecl *BaseD = UniqueBase->getDestructor(); + if (BaseD->getType()->getAs<FunctionType>()->getCallConv() != + D->getType()->getAs<FunctionType>()->getCallConv()) + return true; + return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base), GlobalDecl(BaseD, Dtor_Base), false); diff --git a/test/CodeGenCXX/ctor-dtor-alias.cpp b/test/CodeGenCXX/ctor-dtor-alias.cpp index 235d1650de..d8d1fab7ce 100644 --- a/test/CodeGenCXX/ctor-dtor-alias.cpp +++ b/test/CodeGenCXX/ctor-dtor-alias.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s -// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s +// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s +// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s // RUN: %clang_cc1 -cc1 -triple x86_64--netbsd -emit-llvm \ // RUN: -mconstructor-aliases -O2 %s -o - | FileCheck --check-prefix=CHECK-RAUW %s @@ -133,6 +133,22 @@ namespace test8 { zed foo; } +namespace test9 { +struct foo { + __attribute__((stdcall)) ~foo() { + } +}; + +struct bar : public foo {}; + +void zed() { + // Test that we produce a call to bar's destructor. We used to call foo's, but + // it has a different calling conversion. + // CHECK-DAG: call void @_ZN5test93barD2Ev + bar ptr; +} +} + // CHECK-RAUW: @_ZTV1C = linkonce_odr unnamed_addr constant [4 x i8*] [{{[^@]*}}@_ZTI1C {{[^@]*}}@_ZN1CD2Ev {{[^@]*}}@_ZN1CD0Ev {{[^@]*}}] // r194296 replaced C::~C with B::~B without emitting the later. |
