aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-06-23 11:51:46 +0000
committerHans Wennborg <hans@hanshq.net>2012-06-23 11:51:46 +0000
commit5e2d5dec7736f6f9292d4212dec67295909f1328 (patch)
treeae900f2d4e941e5e66ed601b1f2d0d8ff1f1ec14 /lib/CodeGen/CodeGenModule.cpp
parent2edf0a2520313cde900799b1eb9bd11c9c776afe (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 43d573689c..1d6ddd56de 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/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<TLSModelAttr>()) {
+ const TLSModelAttr *Attr = D->getAttr<TLSModelAttr>();
+ GV->setThreadLocalMode(GetLLVMTLSModel(Attr->getModel()));
+ }
}
if (AddrSpace != Ty->getAddressSpace())