r226361 - Make sure all weak destructors go in a comdat in the ms abi.

Rafael Espindola rafael.espindola at gmail.com
Fri Jan 16 17:47:39 PST 2015


Author: rafael
Date: Fri Jan 16 19:47:39 2015
New Revision: 226361

URL: http://llvm.org/viewvc/llvm-project?rev=226361&view=rev
Log:
Make sure all weak destructors go in a comdat in the ms abi.

Destructors have a special treatment in getFunctionLinkage. Instead of
duplicating the logic, check the resulting linkage.

Modified:
    cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
    cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=226361&r1=226360&r2=226361&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Fri Jan 16 19:47:39 2015
@@ -3080,7 +3080,8 @@ static void emitCXXDestructor(CodeGenMod
     return;
 
   llvm::Function *Fn = CGM.codegenCXXStructor(dtor, dtorType);
-  CGM.maybeSetTrivialComdat(*dtor, *Fn);
+  if (Fn->isWeakForLinker())
+    Fn->setComdat(CGM.getModule().getOrInsertComdat(Fn->getName()));
 }
 
 void MicrosoftCXXABI::emitCXXStructor(const CXXMethodDecl *MD,

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp?rev=226361&r1=226360&r2=226361&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp Fri Jan 16 19:47:39 2015
@@ -206,7 +206,7 @@ F::~F() {
 void foo() {
   F f;
 }
-// DTORS3-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_DF at test2@@UAE at XZ"
+// DTORS3-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_DF at test2@@UAE at XZ"({{.*}} {{.*}} comdat
 //      Do an adjustment from C* to F*.
 // DTORS3:   getelementptr i8* %{{.*}}, i32 20
 // DTORS3:   bitcast i8* %{{.*}} to %"struct.test2::F"*
@@ -365,7 +365,7 @@ void call_vbase_complete(D *d) {
 }
 
 // The complete dtor should call the base dtors for D and the vbase A (once).
-// CHECK: define linkonce_odr x86_thiscallcc void @"\01??_DD at dtors@@QAE at XZ"
+// CHECK: define linkonce_odr x86_thiscallcc void @"\01??_DD at dtors@@QAE at XZ"({{.*}}) {{.*}} comdat
 // CHECK-NOT: call
 // CHECK: call x86_thiscallcc void @"\01??1D at dtors@@QAE at XZ"
 // CHECK-NOT: call





More information about the cfe-commits mailing list