summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-10-05 05:05:40 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-10-05 05:05:40 +0000
commitb3341ea453ca6f6cf41402eec9e4348bf1bd5f42 (patch)
tree235e55ff834b081904cde85e8481053753cc0903 /clang/lib/CodeGen/CGExpr.cpp
parent2a295fd337666999ad2ae9d6549ba846cbdab08b (diff)
downloadbcm5719-llvm-b3341ea453ca6f6cf41402eec9e4348bf1bd5f42.tar.gz
bcm5719-llvm-b3341ea453ca6f6cf41402eec9e4348bf1bd5f42.zip
MS ABI: Implement thread_local for global variables
Summary: This add support for the C++11 feature, thread_local global variables. The ABI Clang implements is an improvement of the MSVC ABI. Sadly, further improvements could be made but not without sacrificing ABI compatibility. The feature is implemented as follows: - All thread_local initialization routines are pointed to from the .CRT$XDU section. - All non-weak thread_local variables have their initialization routines call from a single function instead of getting their own .CRT$XDU section entry. This is done to open up optimization opportunities to the compiler. - All weak thread_local variables have their own .CRT$XDU section entry. This entry is in a COMDAT with the global variable it is initializing; this ensures that we will initialize the global exactly once. - Destructors are registered in the initialization function using __tlregdtor. Differential Revision: http://reviews.llvm.org/D5597 llvm-svn: 219074
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 7b26009a65e..717082a5934 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1822,7 +1822,8 @@ static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
QualType T = E->getType();
// If it's thread_local, emit a call to its wrapper function instead.
- if (VD->getTLSKind() == VarDecl::TLS_Dynamic)
+ if (VD->getTLSKind() == VarDecl::TLS_Dynamic &&
+ CGF.CGM.getCXXABI().usesThreadWrapperFunction())
return CGF.CGM.getCXXABI().EmitThreadLocalVarDeclLValue(CGF, VD, T);
llvm::Value *V = CGF.CGM.GetAddrOfGlobalVar(VD);
OpenPOWER on IntegriCloud