Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -165,7 +165,12 @@ } if (!GV->isDefinition()) + { addFlag(*VariableDIE, dwarf::DW_AT_declaration); + + if (DD->useAllLinkageNames()) + addLinkageName(*VariableDIE, GV->getLinkageName()); + } else addGlobalName(GV->getName(), *VariableDIE, DeclContext); @@ -177,6 +182,7 @@ addTemplateParams(*VariableDIE, DINodeArray(TP)); // Add location. + if (GV->isDefinition()) addLocationAttribute(VariableDIE, GV, GlobalExprs); return VariableDIE;