r226465 - Add comdat to thunks.
Rafael Espindola
rafael.espindola at gmail.com
Mon Jan 19 06:02:15 PST 2015
Author: rafael
Date: Mon Jan 19 08:02:14 2015
New Revision: 226465
URL: http://llvm.org/viewvc/llvm-project?rev=226465&view=rev
Log:
Add comdat to thunks.
Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-thunks.cpp
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=226465&r1=226464&r2=226465&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Mon Jan 19 08:02:14 2015
@@ -377,7 +377,10 @@ void CodeGenFunction::GenerateThunk(llvm
// Set the right linkage.
CGM.setFunctionLinkage(GD, Fn);
-
+
+ if (CGM.supportsCOMDAT() && Fn->isWeakForLinker())
+ Fn->setComdat(CGM.getModule().getOrInsertComdat(Fn->getName()));
+
// Set the right visibility.
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
setThunkVisibility(CGM, MD, Thunk, Fn);
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-thunks.cpp?rev=226465&r1=226464&r2=226465&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-thunks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-thunks.cpp Mon Jan 19 08:02:14 2015
@@ -33,10 +33,10 @@ struct C : A, B {
virtual ~C();
// MANGLING-DAG: declare {{.*}} @"\01??1C@@UAE at XZ"({{.*}})
// MANGLING-DAG: define {{.*}} @"\01??_GC@@UAEPAXI at Z"({{.*}})
- // MANGLING-DAG: define {{.*}} @"\01??_EC@@W3AEPAXI at Z"({{.*}})
+ // MANGLING-DAG: define {{.*}} @"\01??_EC@@W3AEPAXI at Z"({{.*}}) {{.*}} comdat
// MANGLING-X64-DAG: declare {{.*}} @"\01??1C@@UEAA at XZ"({{.*}})
// MANGLING-X64-DAG: define {{.*}} @"\01??_GC@@UEAAPEAXI at Z"({{.*}})
- // MANGLING-X64-DAG: define {{.*}} @"\01??_EC@@W7EAAPEAXI at Z"({{.*}})
+ // MANGLING-X64-DAG: define {{.*}} @"\01??_EC@@W7EAAPEAXI at Z"({{.*}}) {{.*}} comdat
// Overrides public_f() of two subobjects with distinct vfptrs, thus needs a thunk.
virtual void public_f();
@@ -61,7 +61,7 @@ struct C : A, B {
C::C() {} // Emits vftable and forces thunk generation.
-// CODEGEN-LABEL: define linkonce_odr x86_thiscallcc i8* @"\01??_EC@@W3AEPAXI at Z"(%struct.C* %this, i32 %should_call_delete)
+// CODEGEN-LABEL: define linkonce_odr x86_thiscallcc i8* @"\01??_EC@@W3AEPAXI at Z"(%struct.C* %this, i32 %should_call_delete) {{.*}} comdat
// CODEGEN: getelementptr i8* {{.*}}, i32 -4
// FIXME: should actually call _EC, not _GC.
// CODEGEN: call x86_thiscallcc i8* @"\01??_GC@@UAEPAXI at Z"
More information about the cfe-commits
mailing list