[llvm-branch-commits] [cfe-branch] r206059 - Merging r203007:

Tom Stellard thomas.stellard at amd.com
Fri Apr 11 12:36:51 PDT 2014


Author: tstellar
Date: Fri Apr 11 14:36:51 2014
New Revision: 206059

URL: http://llvm.org/viewvc/llvm-project?rev=206059&view=rev
Log:
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.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/lib/CodeGen/CGCXX.cpp
    cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp

Modified: cfe/branches/release_34/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/CodeGen/CGCXX.cpp?rev=206059&r1=206058&r2=206059&view=diff
==============================================================================
--- cfe/branches/release_34/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/branches/release_34/lib/CodeGen/CGCXX.cpp Fri Apr 11 14:36:51 2014
@@ -92,7 +92,13 @@ bool CodeGenModule::TryEmitBaseDestructo
   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);

Modified: cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=206059&r1=206058&r2=206059&view=diff
==============================================================================
--- cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp Fri Apr 11 14:36:51 2014
@@ -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.
 





More information about the llvm-branch-commits mailing list