From cdf7ef5437f2cd76bd6b0246cd11b1837d79104e Mon Sep 17 00:00:00 2001 From: John McCall Date: Sat, 6 Nov 2010 09:44:32 +0000 Subject: 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 --- clang/lib/CodeGen/CodeGenModule.cpp | 5 ++++- 1 file changed, 4 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 a2b80bea..a3cf69b 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()); -- cgit v1.1