From db4f61f9fb0edc16b5568af0bf6a6729718b349f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 22 Apr 2013 08:06:17 +0000 Subject: [PATCH] Don't emit _ZTW wrappers for TLS variables which don't use the C++ thread_local keyword. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180004 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 3 ++- test/CodeGen/thread-specifier.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index fdd3568472..5a10602589 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1479,7 +1479,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, } if (D->getTLSKind()) { - CXXThreadLocals.push_back(std::make_pair(D, GV)); + if (D->getTLSKind() == VarDecl::TLS_Dynamic) + CXXThreadLocals.push_back(std::make_pair(D, GV)); setTLSMode(GV, *D); } } diff --git a/test/CodeGen/thread-specifier.c b/test/CodeGen/thread-specifier.c index a2d3e62c8c..8e21651cd8 100644 --- a/test/CodeGen/thread-specifier.c +++ b/test/CodeGen/thread-specifier.c @@ -10,6 +10,9 @@ // CHECK: @i = thread_local(initialexec) global // CHECK: @j = thread_local(localexec) global +// CHECK-NOT: @_ZTW +// CHECK-NOT: @_ZTH + __thread int a; extern __thread int b; int c() { return *&b; } -- 2.40.0