summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-11-06 09:44:32 +0000
committerJohn McCall <rjmccall@apple.com>2010-11-06 09:44:32 +0000
commitcdf7ef5437f2cd76bd6b0246cd11b1837d79104e (patch)
tree33ffe1037fdadbfadd82e5f2348e45edb53e4c27 /clang/lib/CodeGen/CodeGenModule.cpp
parent8b0a71fc315f561e3d9889c924fb2618ffdf5a27 (diff)
downloadbcm5719-llvm-cdf7ef5437f2cd76bd6b0246cd11b1837d79104e.tar.gz
bcm5719-llvm-cdf7ef5437f2cd76bd6b0246cd11b1837d79104e.zip
Simplify the logic for emitting guard variables for template static
data members by delaying the emission of the initializer until after linkage and visibility have been set on the global. Also, don't emit a guard unless the variable actually ends up with vague linkage, and don't use thread-safe statics in any case. llvm-svn: 118336
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index a2b80bea6c0..a3cf69b675c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1102,7 +1102,6 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
T = D->getType();
if (getLangOptions().CPlusPlus) {
- EmitCXXGlobalVarDeclInitFunc(D);
Init = EmitNullConstant(T);
NonConstInit = true;
} else {
@@ -1184,6 +1183,10 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
SetCommonAttributes(D, GV);
+ // Emit the initializer function if necessary.
+ if (NonConstInit)
+ EmitCXXGlobalVarDeclInitFunc(D, GV);
+
// Emit global variable debug information.
if (CGDebugInfo *DI = getDebugInfo()) {
DI->setLocation(D->getLocation());
OpenPOWER on IntegriCloud