]> granicus.if.org Git - clang/commitdiff
[MS ABI] Add /include directives for dynamic TLS
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 12 Sep 2016 02:51:43 +0000 (02:51 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 12 Sep 2016 02:51:43 +0000 (02:51 +0000)
MSVC emits /include directives in the .drective section for the
__dyn_tls_init function (decorated as ___dyn_tls_init@12 for 32-bit).

This fixes PR30347.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281189 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGenCXX/ms-thread_local.cpp

index 58fe5d39eb0c3d28c6d480c710975d4c453ab1f7..7220768a4895a490372eb5e391cd337ffad54858 100644 (file)
@@ -2211,6 +2211,14 @@ void MicrosoftCXXABI::EmitThreadLocalInitFuncs(
     CodeGenModule &CGM, ArrayRef<const VarDecl *> CXXThreadLocals,
     ArrayRef<llvm::Function *> CXXThreadLocalInits,
     ArrayRef<const VarDecl *> CXXThreadLocalInitVars) {
+  if (CXXThreadLocalInits.empty())
+    return;
+
+  CGM.AppendLinkerOptions(CGM.getTarget().getTriple().getArch() ==
+                                  llvm::Triple::x86
+                              ? "/include:___dyn_tls_init@12"
+                              : "/include:__dyn_tls_init");
+
   // This will create a GV in the .CRT$XDU section.  It will point to our
   // initialization function.  The CRT will call all of these function
   // pointers at start-up time and, eventually, at thread-creation time.
index c29473fd6fca009c51352ec417d6214ac6896df1..5183ab5c32e1c6f9330b91c76bebbb6badf90b98 100644 (file)
@@ -26,3 +26,8 @@ A f() {
   (void)b;
   return c;
 }
+
+// CHECK: !llvm.module.flags = !{{{.*}}}
+// CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[link_opts:[0-9]+]]}
+// CHECK: ![[link_opts]] = !{![[dyn_tls_init:[0-9]+]]}
+// CHECK: ![[dyn_tls_init]] = !{!"/include:___dyn_tls_init@12"}