[PATCH] D71572: [ItaniumCXXABI] Make tls wrappers properly comdat
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 13 13:43:31 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG810b28edb3f6: [ItaniumCXXABI] Make tls wrappers properly comdat (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71572/new/
https://reviews.llvm.org/D71572
Files:
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGenCXX/cxx11-thread-local-reference.cpp
clang/test/CodeGenCXX/cxx11-thread-local.cpp
clang/test/CodeGenCXX/tls-init-funcs.cpp
clang/test/OpenMP/threadprivate_codegen.cpp
Index: clang/test/OpenMP/threadprivate_codegen.cpp
===================================================================
--- clang/test/OpenMP/threadprivate_codegen.cpp
+++ clang/test/OpenMP/threadprivate_codegen.cpp
@@ -648,15 +648,15 @@
// CHECK-TLS: call void [[ARR_X_TLS_INIT]]
// CHECK-TLS: ret [2 x [3 x [[S1]]]]* [[ARR_X]]
// CHECK-TLS: }
-// CHECK-TLS: define {{.*}} i32* [[ST_INT_ST_TLS_INITD]] {{#[0-9]+}} {
+// CHECK-TLS: define {{.*}} i32* [[ST_INT_ST_TLS_INITD]] {{#[0-9]+}} comdat {
// CHECK-TLS-NOT: call
// CHECK-TLS: ret i32* [[ST_INT_ST]]
// CHECK-TLS: }
-// CHECK-TLS: define {{.*}} float* [[ST_FLOAT_ST_TLS_INITD]] {{#[0-9]+}} {
+// CHECK-TLS: define {{.*}} float* [[ST_FLOAT_ST_TLS_INITD]] {{#[0-9]+}} comdat {
// CHECK-TLS-NOT: call
// CHECK-TLS: ret float* [[ST_FLOAT_ST]]
// CHECK-TLS: }
-// CHECK-TLS: define {{.*}} [[S4]]* [[ST_S4_ST_TLS_INITD]] {{#[0-9]+}} {
+// CHECK-TLS: define {{.*}} [[S4]]* [[ST_S4_ST_TLS_INITD]] {{#[0-9]+}} comdat {
// CHECK-TLS: call void [[ST_S4_ST_TLS_INIT]]
// CHECK-TLS: ret [[S4]]* [[ST_S4_ST]]
// CHECK-TLS: }
Index: clang/test/CodeGenCXX/tls-init-funcs.cpp
===================================================================
--- clang/test/CodeGenCXX/tls-init-funcs.cpp
+++ clang/test/CodeGenCXX/tls-init-funcs.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.8 -std=c++1y -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -std=c++1y -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MINGW
// CHECK: @a = internal thread_local global
// CHECK: @_Z2vtIiE = linkonce_odr thread_local global i32 5
@@ -10,6 +11,9 @@
// CHECK-DAG: define weak_odr hidden cxx_fast_tlscc i32* @_ZTW2vtIvE()
// CHECK-DAG: define {{.*}} @_ZTW1a
+// MINGW-DAG: define weak_odr hidden i32* @_ZTW2vtIiE() {{.*}} comdat
+// MINGW-DAG: define weak_odr hidden i32* @_ZTW2vtIvE() {{.*}} comdat
+
struct A {
~A();
};
Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -204,22 +204,19 @@
// DARWIN: declare i32 @_tlv_atexit(void (i8*)*, i8*, i8*)
// DARWIN: declare cxx_fast_tlscc i32* @_ZTWN1VIcE1mE()
-// LINUX: define linkonce_odr hidden i32* @_ZTWN1VIcE1mE()
-// LINUX-NOT: comdat
+// LINUX: define linkonce_odr hidden i32* @_ZTWN1VIcE1mE() {{#[0-9]+}} comdat {
// LINUX: br i1 icmp ne (void ()* @_ZTHN1VIcE1mE,
// LINUX: call void @_ZTHN1VIcE1mE()
// LINUX: ret i32* @_ZN1VIcE1mE
// DARWIN: declare cxx_fast_tlscc i32* @_ZTWN1WIcE1mE()
-// LINUX: define linkonce_odr hidden i32* @_ZTWN1WIcE1mE()
-// LINUX-NOT: comdat
+// LINUX: define linkonce_odr hidden i32* @_ZTWN1WIcE1mE() {{#[0-9]+}} comdat {
// LINUX: br i1 icmp ne (void ()* @_ZTHN1WIcE1mE,
// LINUX: call void @_ZTHN1WIcE1mE()
// LINUX: ret i32* @_ZN1WIcE1mE
// DARWIN: declare cxx_fast_tlscc {{.*}}* @_ZTWN1XIcE1mE()
-// LINUX: define linkonce_odr hidden {{.*}}* @_ZTWN1XIcE1mE()
-// LINUX-NOT: comdat
+// LINUX: define linkonce_odr hidden {{.*}}* @_ZTWN1XIcE1mE() {{#[0-9]+}} comdat {
// LINUX: br i1 icmp ne (void ()* @_ZTHN1XIcE1mE,
// LINUX: call void @_ZTHN1XIcE1mE()
// LINUX: ret {{.*}}* @_ZN1XIcE1mE
Index: clang/test/CodeGenCXX/cxx11-thread-local-reference.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx11-thread-local-reference.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local-reference.cpp
@@ -21,7 +21,7 @@
// DARWIN: call cxx_fast_tlscc i32* @_ZTW1r()
// CHECK: ret i32* %{{.*}}
-// LINUX: define weak_odr hidden i32* @_ZTW1r() [[ATTR0:#[0-9]+]] {
+// LINUX: define weak_odr hidden i32* @_ZTW1r() [[ATTR0:#[0-9]+]] comdat {
// DARWIN: define cxx_fast_tlscc i32* @_ZTW1r() [[ATTR1:#[0-9]+]] {
// LINUX: call void @_ZTH1r()
// DARWIN: call cxx_fast_tlscc void @_ZTH1r()
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2546,6 +2546,9 @@
llvm::Function::Create(FnTy, getThreadLocalWrapperLinkage(VD, CGM),
WrapperName.str(), &CGM.getModule());
+ if (CGM.supportsCOMDAT() && Wrapper->isWeakForLinker())
+ Wrapper->setComdat(CGM.getModule().getOrInsertComdat(Wrapper->getName()));
+
CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, Wrapper);
// Always resolve references to the wrapper at link time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71572.237771.patch
Type: text/x-patch
Size: 4541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200113/bd6f98d8/attachment.bin>
More information about the cfe-commits
mailing list