diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-17 01:47:39 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-17 01:47:39 +0000 |
commit | d3e0469a843b32f9f244280a286d2465d9733e6a (patch) | |
tree | 2bb62500c448aa1ef77c976d30b9a58320597520 | |
parent | 37f316afaf69cbdfb1f5959342ac74a888943ed6 (diff) | |
download | bcm5719-llvm-d3e0469a843b32f9f244280a286d2465d9733e6a.tar.gz bcm5719-llvm-d3e0469a843b32f9f244280a286d2465d9733e6a.zip |
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.
llvm-svn: 226361
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 3 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-structors.cpp | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index c7e66e9465f..12029bc13b1 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -3080,7 +3080,8 @@ static void emitCXXDestructor(CodeGenModule &CGM, const CXXDestructorDecl *dtor, 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, diff --git a/clang/test/CodeGenCXX/microsoft-abi-structors.cpp b/clang/test/CodeGenCXX/microsoft-abi-structors.cpp index 7a990bef791..93d1c24dfbc 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-structors.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-structors.cpp @@ -206,7 +206,7 @@ F::~F() { void foo() { F f; } -// DTORS3-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_DF@test2@@UAE@XZ" +// DTORS3-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_DF@test2@@UAE@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@dtors@@QAE@XZ" +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??_DD@dtors@@QAE@XZ"({{.*}}) {{.*}} comdat // CHECK-NOT: call // CHECK: call x86_thiscallcc void @"\01??1D@dtors@@QAE@XZ" // CHECK-NOT: call |