diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-06-28 08:01:44 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-06-28 08:01:44 +0000 |
commit | de981f3ff163bc9ec69e4c5e7316e94276412993 (patch) | |
tree | 5b965d25849d6216a431f45337cd6601efa2e632 /lib/CodeGen/CGDecl.cpp | |
parent | b6ebd4490235c9ea6016530d623c46d0b9ce565b (diff) |
Add -ftls-model command-line flag.
This allows for setting the default TLS model. (PR9788)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 08a938254b..be6638e0e5 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -183,26 +183,20 @@ CodeGenFunction::CreateStaticVarDecl(const VarDecl &D, else Name = GetStaticDeclName(*this, D, Separator); - llvm::GlobalVariable::ThreadLocalMode TLM; - TLM = D.isThreadSpecified() ? llvm::GlobalVariable::GeneralDynamicTLSModel - : llvm::GlobalVariable::NotThreadLocal; - - // Set the TLS mode if it it's explicitly specified. - if (D.hasAttr<TLSModelAttr>()) { - assert(D.isThreadSpecified() && "Can't have TLS model on non-tls var."); - const TLSModelAttr *Attr = D.getAttr<TLSModelAttr>(); - TLM = CodeGenModule::GetLLVMTLSModel(Attr->getModel()); - } - llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty); llvm::GlobalVariable *GV = new llvm::GlobalVariable(CGM.getModule(), LTy, Ty.isConstant(getContext()), Linkage, - CGM.EmitNullConstant(D.getType()), Name, 0, TLM, + CGM.EmitNullConstant(D.getType()), Name, 0, + llvm::GlobalVariable::NotThreadLocal, CGM.getContext().getTargetAddressSpace(Ty)); GV->setAlignment(getContext().getDeclAlign(&D).getQuantity()); if (Linkage != llvm::GlobalValue::InternalLinkage) GV->setVisibility(CurFn->getVisibility()); + + if (D.isThreadSpecified()) + CGM.setTLSMode(GV, D); + return GV; } |