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
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user