Skip to content

Commit

Permalink
[MS ABI] Add /include directives for dynamic TLS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
majnemer committed Sep 12, 2016
1 parent 359c455 commit c5d3857
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/CodeGen/MicrosoftCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions test/CodeGenCXX/ms-thread_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

0 comments on commit c5d3857

Please sign in to comment.