From d3b01bc7c6735a78ebdff0071647a15de5716bc7 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Sat, 23 Jun 2012 11:51:46 +0000 Subject: Support the tls_model attribute (PR9788) This adds support for the tls_model attribute. This allows the user to choose a TLS model that is better than what LLVM would select by default. For example, a variable might be declared as: __thread int x __attribute__((tls_model("initial-exec"))); if it will not be used in a shared library that is dlopen'ed. This depends on LLVM r159077. llvm-svn: 159078 --- clang/lib/CodeGen/CodeGenModule.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 43d573689c9..1d6ddd56de3 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1187,7 +1187,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, new llvm::GlobalVariable(getModule(), Ty->getElementType(), false, llvm::GlobalValue::ExternalLinkage, 0, MangledName, 0, - false, AddrSpace); + llvm::GlobalVariable::NotThreadLocal, AddrSpace); // Handle things which are present even on external declarations. if (D) { @@ -1211,6 +1211,12 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, } GV->setThreadLocal(D->isThreadSpecified()); + + // Set the TLS model if it it's explicitly specified. + if (D->hasAttr()) { + const TLSModelAttr *Attr = D->getAttr(); + GV->setThreadLocalMode(GetLLVMTLSModel(Attr->getModel())); + } } if (AddrSpace != Ty->getAddressSpace()) -- cgit v1.2.3