[PATCH] D102970: [clang] [MinGW] Don't mark emutls variables as DSO local
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 27 13:51:33 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e4cf807aeaf: [clang] [MinGW] Don't mark emutls variables as DSO local (authored by mstorsjo).
Changed prior to commit:
https://reviews.llvm.org/D102970?vs=347216&id=348379#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102970/new/
https://reviews.llvm.org/D102970
Files:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/dso-local-executable.c
Index: clang/test/CodeGen/dso-local-executable.c
===================================================================
--- clang/test/CodeGen/dso-local-executable.c
+++ clang/test/CodeGen/dso-local-executable.c
@@ -9,13 +9,15 @@
// COFF-DAG: define dso_local i32* @zed()
// COFF-DAG: declare dllimport void @import_func()
-// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck --check-prefixes=MINGW,MINGW-NATIVE_TLS %s
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - -femulated-tls | FileCheck --check-prefixes=MINGW,MINGW-EMUTLS %s
// MINGW: @baz = dso_local global i32 42
// MINGW-NEXT: @import_var = external dllimport global i32
// MINGW-NEXT: @weak_bar = extern_weak global i32
// MINGW-NEXT: @bar = external global i32
// MINGW-NEXT: @local_thread_var = dso_local thread_local global i32 42
-// MINGW-NEXT: @thread_var = external dso_local thread_local global i32
+// MINGW-NATIVE_TLS-NEXT: @thread_var = external dso_local thread_local global i32
+// MINGW-EMUTLS-NEXT: @thread_var = external thread_local global i32
// MINGW-DAG: declare dso_local void @foo()
// MINGW-DAG: define dso_local i32* @zed()
// MINGW-DAG: declare dllimport void @import_func()
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -986,8 +986,13 @@
// In MinGW, variables without DLLImport can still be automatically
// imported from a DLL by the linker; don't mark variables that
// potentially could come from another DLL as DSO local.
+
+ // With EmulatedTLS, TLS variables can be autoimported from other DLLs
+ // (and this actually happens in the public interface of libstdc++), so
+ // such variables can't be marked as DSO local. (Native TLS variables
+ // can't be dllimported at all, though.)
if (GV->isDeclarationForLinker() && isa<llvm::GlobalVariable>(GV) &&
- !GV->isThreadLocal())
+ (!GV->isThreadLocal() || CGM.getCodeGenOpts().EmulatedTLS))
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102970.348379.patch
Type: text/x-patch
Size: 2216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210527/4c7d37cb/attachment.bin>
More information about the cfe-commits
mailing list