Hi majnemer,
Previously we were not assigning a comdat to thunks in the Microsoft
ABI, which
would have required us to emit these functions outside of a comdat.
(Due to an inconsistency in how we were emitting objects, we
were getting this right most of the time, but only when compiling
without function sections.) This code generator change causes
us to create a comdat for each thunk.
http://reviews.llvm.org/D10829
Files:
lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGenCXX/microsoft-abi-thunks.cpp
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===================================================================
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -308,6 +308,9 @@
Thunk->setLinkage(llvm::GlobalValue::WeakODRLinkage);
else
Thunk->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
+
+ if (Linkage != GVA_Internal)
+ Thunk->setComdat(CGM.getModule().getOrInsertComdat(Thunk->getName()));
}
llvm::Value *performThisAdjustment(CodeGenFunction &CGF, llvm::Value *This,
Index: test/CodeGenCXX/microsoft-abi-thunks.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-thunks.cpp
+++ test/CodeGenCXX/microsoft-abi-thunks.cpp
@@ -91,7 +91,7 @@
E::E() {} // Emits vftable and forces thunk generation.
-// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.C*
@"\01?goo@E@@QAEPAUB@@XZ"
+// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.C*
@"\01?goo@E@@QAEPAUB@@XZ"{{.*}} comdat
// CODEGEN: call x86_thiscallcc %struct.C* @"\01?goo@E@@UAEPAUC@@XZ"
// CODEGEN: getelementptr inbounds i8, i8* {{.*}}, i32 4
// CODEGEN: ret
@@ -124,7 +124,7 @@
I::I() {} // Emits vftable and forces thunk generation.
-// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.{{[BF]}}*
@"\01?goo@I@@QAEPAUB@@XZ"
+// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.{{[BF]}}*
@"\01?goo@I@@QAEPAUB@@XZ"{{.*}} comdat
// CODEGEN: %[[ORIG_RET:.*]] = call x86_thiscallcc %struct.F*
@"\01?goo@I@@UAEPAUF@@XZ"
// CODEGEN: %[[ORIG_RET_i8:.*]] = bitcast %struct.F* %[[ORIG_RET]] to i8*
// CODEGEN: %[[VBPTR_i8:.*]] = getelementptr inbounds i8, i8*
%[[ORIG_RET_i8]], i32 4
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===================================================================
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -308,6 +308,9 @@
Thunk->setLinkage(llvm::GlobalValue::WeakODRLinkage);
else
Thunk->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
+
+ if (Linkage != GVA_Internal)
+ Thunk->setComdat(CGM.getModule().getOrInsertComdat(Thunk->getName()));
}
llvm::Value *performThisAdjustment(CodeGenFunction &CGF, llvm::Value *This,
Index: test/CodeGenCXX/microsoft-abi-thunks.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-thunks.cpp
+++ test/CodeGenCXX/microsoft-abi-thunks.cpp
@@ -91,7 +91,7 @@
E::E() {} // Emits vftable and forces thunk generation.
-// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.C* @"\01?goo@E@@QAEPAUB@@XZ"
+// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.C* @"\01?goo@E@@QAEPAUB@@XZ"{{.*}} comdat
// CODEGEN: call x86_thiscallcc %struct.C* @"\01?goo@E@@UAEPAUC@@XZ"
// CODEGEN: getelementptr inbounds i8, i8* {{.*}}, i32 4
// CODEGEN: ret
@@ -124,7 +124,7 @@
I::I() {} // Emits vftable and forces thunk generation.
-// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.{{[BF]}}* @"\01?goo@I@@QAEPAUB@@XZ"
+// CODEGEN-LABEL: define weak_odr x86_thiscallcc %struct.{{[BF]}}* @"\01?goo@I@@QAEPAUB@@XZ"{{.*}} comdat
// CODEGEN: %[[ORIG_RET:.*]] = call x86_thiscallcc %struct.F* @"\01?goo@I@@UAEPAUF@@XZ"
// CODEGEN: %[[ORIG_RET_i8:.*]] = bitcast %struct.F* %[[ORIG_RET]] to i8*
// CODEGEN: %[[VBPTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ORIG_RET_i8]], i32 4
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits