[PATCH] D71716: [ItaniumCXXABI] Don't mark an extern_weak init function as dso_local on windows

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 19 09:43:22 PST 2019


mstorsjo created this revision.
mstorsjo added reviewers: rnk, smeenai, rsmith.
Herald added a project: clang.

Since 6bf108d77a3c, we try to not mark extern_weak symbols as dso_local, to allow using COFF stubs for references to those symbols (as the symbol may be missing, resolving to an absolute address zero, outside of the current DSO).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71716

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/mingw-thread-local.cpp


Index: clang/test/CodeGenCXX/mingw-thread-local.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/mingw-thread-local.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-w64-mingw32 | FileCheck %s
+
+extern thread_local int var;
+
+int get() {
+  return var;
+}
+
+// CHECK: declare extern_weak void @_ZTH3var()
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2690,7 +2690,9 @@
 
     if (Init) {
       Init->setVisibility(Var->getVisibility());
-      Init->setDSOLocal(Var->isDSOLocal());
+      // Don't mark an extern_weak function DSO local on windows.
+      if (!CGM.getTriple().isOSWindows() || !Init->hasExternalWeakLinkage())
+        Init->setDSOLocal(Var->isDSOLocal());
     }
 
     llvm::LLVMContext &Context = CGM.getModule().getContext();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71716.234740.patch
Type: text/x-patch
Size: 998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191219/c9482832/attachment-0001.bin>


More information about the cfe-commits mailing list