Author: majnemer Date: Sun Sep 11 21:51:43 2016 New Revision: 281189 URL: http://llvm.org/viewvc/llvm-project?rev=281189&view=rev Log: [MS ABI] Add /include directives for dynamic TLS
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. Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/test/CodeGenCXX/ms-thread_local.cpp Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=281189&r1=281188&r2=281189&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Sun Sep 11 21:51:43 2016 @@ -2211,6 +2211,14 @@ void MicrosoftCXXABI::EmitThreadLocalIni 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. Modified: cfe/trunk/test/CodeGenCXX/ms-thread_local.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ms-thread_local.cpp?rev=281189&r1=281188&r2=281189&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/ms-thread_local.cpp (original) +++ cfe/trunk/test/CodeGenCXX/ms-thread_local.cpp Sun Sep 11 21:51:43 2016 @@ -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"} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits