diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-16 15:37:11 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-16 15:37:11 +0000 |
commit | 694cb5d9b7724a0c6dba3adbf7c855e847a6f0de (patch) | |
tree | 4bde9bc747b383e6ec885d63636ff610c88ceb84 | |
parent | 5450a9635aefae51216f00eb0223a55271e51bb6 (diff) | |
download | bcm5719-llvm-694cb5d9b7724a0c6dba3adbf7c855e847a6f0de.tar.gz bcm5719-llvm-694cb5d9b7724a0c6dba3adbf7c855e847a6f0de.zip |
Add comdats to constructs and destructor in the microsoft abi.
llvm-svn: 226280
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 6 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-structors.cpp | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index c80db7d18a1..a7671d80ff5 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -3037,7 +3037,8 @@ static void emitCXXConstructor(CodeGenModule &CGM, const CXXConstructorDecl *ctor, StructorType ctorType) { // There are no constructor variants, always emit the complete destructor. - CGM.codegenCXXStructor(ctor, StructorType::Complete); + llvm::Function *Fn = CGM.codegenCXXStructor(ctor, StructorType::Complete); + CGM.maybeSetTrivialComdat(*ctor, *Fn); } static void emitCXXDestructor(CodeGenModule &CGM, const CXXDestructorDecl *dtor, @@ -3063,7 +3064,8 @@ static void emitCXXDestructor(CodeGenModule &CGM, const CXXDestructorDecl *dtor, if (dtorType == StructorType::Base && !CGM.TryEmitBaseDestructorAsAlias(dtor)) return; - CGM.codegenCXXStructor(dtor, dtorType); + llvm::Function *Fn = CGM.codegenCXXStructor(dtor, dtorType); + CGM.maybeSetTrivialComdat(*dtor, *Fn); } 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 01d72e0aed5..7a990bef791 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-structors.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-structors.cpp @@ -19,7 +19,7 @@ class A { void no_constructor_destructor_infinite_recursion() { A a; -// CHECK: define linkonce_odr x86_thiscallcc %"class.basic::A"* @"\01??0A@basic@@QAE@XZ"(%"class.basic::A"* returned %this) +// CHECK: define linkonce_odr x86_thiscallcc %"class.basic::A"* @"\01??0A@basic@@QAE@XZ"(%"class.basic::A"* returned %this) {{.*}} comdat {{.*}} { // CHECK: [[THIS_ADDR:%[.0-9A-Z_a-z]+]] = alloca %"class.basic::A"*, align 4 // CHECK-NEXT: store %"class.basic::A"* %this, %"class.basic::A"** [[THIS_ADDR]], align 4 // CHECK-NEXT: [[T1:%[.0-9A-Z_a-z]+]] = load %"class.basic::A"** [[THIS_ADDR]] @@ -46,7 +46,7 @@ B::B() { struct C { virtual ~C() { -// DTORS: define linkonce_odr x86_thiscallcc i8* @"\01??_GC@basic@@UAEPAXI@Z"(%"struct.basic::C"* %this, i32 %should_call_delete) +// DTORS: define linkonce_odr x86_thiscallcc i8* @"\01??_GC@basic@@UAEPAXI@Z"(%"struct.basic::C"* %this, i32 %should_call_delete) {{.*}} comdat {{.*}} { // DTORS: store i32 %should_call_delete, i32* %[[SHOULD_DELETE_VAR:[0-9a-z._]+]], align 4 // DTORS: store i8* %{{.*}}, i8** %[[RETVAL:[0-9a-z._]+]] // DTORS: %[[SHOULD_DELETE_VALUE:[0-9a-z._]+]] = load i32* %[[SHOULD_DELETE_VAR]] |