summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/ItaniumCXXABI.cpp5
-rw-r--r--clang/test/CodeGenCXX/cxx11-thread-local.cpp8
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 4b1c1c255af..d11d1728afe 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1582,8 +1582,9 @@ ItaniumCXXABI::getOrCreateThreadLocalWrapper(const VarDecl *VD,
llvm::FunctionType *FnTy = llvm::FunctionType::get(RetTy, false);
llvm::Function *Wrapper = llvm::Function::Create(
- FnTy, getThreadLocalWrapperLinkage(Var->getLinkage()), WrapperName.str(),
- &CGM.getModule());
+ FnTy, getThreadLocalWrapperLinkage(
+ CGM.getLLVMLinkageVarDefinition(VD, /*isConstant=*/false)),
+ WrapperName.str(), &CGM.getModule());
// Always resolve references to the wrapper at link time.
Wrapper->setVisibility(llvm::GlobalValue::HiddenVisibility);
return Wrapper;
diff --git a/clang/test/CodeGenCXX/cxx11-thread-local.cpp b/clang/test/CodeGenCXX/cxx11-thread-local.cpp
index b91f46d5d49..5843a343b86 100644
--- a/clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ b/clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -145,6 +145,14 @@ int PR19254::f() {
return this->n;
}
+namespace {
+thread_local int anon_i{1};
+}
+void set_anon_i() {
+ anon_i = 2;
+}
+// CHECK-LABEL: define internal hidden i32* @_ZTWN12_GLOBAL__N_16anon_iE()
+
// CHECK: define {{.*}} @[[V_M_INIT:.*]]()
// CHECK: load i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*)
// CHECK: %[[V_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
OpenPOWER on IntegriCloud