diff --git a/include/llvm/CodeGen/MachineDebugInfo.h b/include/llvm/CodeGen/MachineDebugInfo.h index 46078d25efa..aa968f49a80 100644 --- a/include/llvm/CodeGen/MachineDebugInfo.h +++ b/include/llvm/CodeGen/MachineDebugInfo.h @@ -53,7 +53,8 @@ class StructType; // Debug info constants. enum { - LLVMDebugVersion = (5 << 16), // Current version of debug information. + LLVMDebugVersion = (6 << 16), // Current version of debug information. + LLVMDebugVersion5 = (5 << 16), // Constant for version 5. LLVMDebugVersion4 = (4 << 16), // Constant for version 4. LLVMDebugVersionMask = 0xffff0000 // Mask for version number. }; @@ -582,7 +583,8 @@ class GlobalDesc : public AnchoredDesc { private: DebugInfoDesc *Context; // Context debug descriptor. std::string Name; // Global name. - std::string DisplayName; // C++ unmangled name. + std::string FullName; // Fully qualified name. + std::string LinkageName; // Name for binding to MIPS linkage. DebugInfoDesc *File; // Defined compile unit (may be NULL.) unsigned Line; // Defined line# (may be zero.) DebugInfoDesc *TyDesc; // Type debug descriptor. @@ -596,7 +598,8 @@ public: // Accessors DebugInfoDesc *getContext() const { return Context; } const std::string &getName() const { return Name; } - const std::string &getDisplayName() const { return DisplayName; } + const std::string &getFullName() const { return FullName; } + const std::string &getLinkageName() const { return LinkageName; } CompileUnitDesc *getFile() const { return static_cast(File); } @@ -608,7 +611,8 @@ public: bool isDefinition() const { return IsDefinition; } void setContext(DebugInfoDesc *C) { Context = C; } void setName(const std::string &N) { Name = N; } - void setDisplayName(const std::string &N) { DisplayName = N; } + void setFullName(const std::string &N) { FullName = N; } + void setLinkageName(const std::string &N) { LinkageName = N; } void setFile(CompileUnitDesc *U) { File = static_cast(U); } @@ -618,9 +622,6 @@ public: } void setIsStatic(bool IS) { IsStatic = IS; } void setIsDefinition(bool ID) { IsDefinition = ID; } - bool hasMangledName() const { - return !DisplayName.empty(); - } /// ApplyToFields - Target the visitor to the fields of the GlobalDesc. /// diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index f76316937d8..5058ccaa2cb 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -1587,11 +1587,13 @@ private: DIE *Static = new DIE(DW_TAG_variable); // Add name and mangled name. - const std::string &Name = StaticDesc->getDisplayName(); - const std::string &MangledName = StaticDesc->getName(); + const std::string &Name = StaticDesc->getName(); + const std::string &LinkageName = StaticDesc->getLinkageName(); AddString(Static, DW_AT_name, DW_FORM_string, Name); - AddString(Static, DW_AT_MIPS_linkage_name, DW_FORM_string, - MangledName); + if (!LinkageName.empty()) { + AddString(Static, DW_AT_MIPS_linkage_name, DW_FORM_string, + LinkageName); + } // Add location. AddSourceLine(Static, StaticDesc->getFile(), StaticDesc->getLine()); @@ -1613,17 +1615,15 @@ private: DIE *Method = new DIE(DW_TAG_subprogram); // Add name and mangled name. - const std::string &Name = MethodDesc->getDisplayName(); - const std::string &MangledName = MethodDesc->getName(); - bool IsCTor = false; + const std::string &Name = MethodDesc->getName(); + const std::string &LinkageName = MethodDesc->getLinkageName(); - if (Name.empty()) { - AddString(Method, DW_AT_name, DW_FORM_string, MangledName); - IsCTor = TyDesc->getName() == MangledName; - } else { - AddString(Method, DW_AT_name, DW_FORM_string, Name); + AddString(Method, DW_AT_name, DW_FORM_string, Name); + bool IsCTor = TyDesc->getName() == Name; + + if (!LinkageName.empty()) { AddString(Method, DW_AT_MIPS_linkage_name, DW_FORM_string, - MangledName); + LinkageName); } // Add location. @@ -1752,16 +1752,15 @@ private: // Get the global variable itself. GlobalVariable *GV = GVD->getGlobalVariable(); - const std::string &Name = GVD->hasMangledName() ? GVD->getDisplayName() - : GVD->getName(); - const std::string &MangledName = GVD->hasMangledName() ? GVD->getName() - : ""; + const std::string &Name = GVD->getName(); + const std::string &FullName = GVD->getFullName(); + const std::string &LinkageName = GVD->getLinkageName(); // Create the global's variable DIE. DIE *VariableDie = new DIE(DW_TAG_variable); AddString(VariableDie, DW_AT_name, DW_FORM_string, Name); - if (!MangledName.empty()) { + if (!LinkageName.empty()) { AddString(VariableDie, DW_AT_MIPS_linkage_name, DW_FORM_string, - MangledName); + LinkageName); } AddType(VariableDie, GVD->getType(), Unit); AddUInt(VariableDie, DW_AT_external, DW_FORM_flag, 1); @@ -1769,14 +1768,11 @@ private: // Add source line info if available. AddSourceLine(VariableDie, UnitDesc, GVD->getLine()); - // Work up linkage name. - const std::string LinkageName = Asm->getGlobalLinkName(GV); - // Add address. DIEBlock *Block = new DIEBlock(); AddUInt(Block, 0, DW_FORM_data1, DW_OP_addr); - AddObjectLabel(Block, 0, DW_FORM_udata, LinkageName); - AddBlock(VariableDie, DW_AT_location, 0, Block); + AddObjectLabel(Block, 0, DW_FORM_udata, Asm->getGlobalLinkName(GV)); + AddBlock(VariableDie, DW_AT_location, 0, Block); // Add to map. Slot = VariableDie; @@ -1786,7 +1782,7 @@ private: // Expose as global. // FIXME - need to check external flag. - Unit->AddGlobal(Name, VariableDie); + Unit->AddGlobal(FullName, VariableDie); return VariableDie; } @@ -1804,17 +1800,16 @@ private: if (Slot) return Slot; // Gather the details (simplify add attribute code.) - const std::string &Name = SPD->hasMangledName() ? SPD->getDisplayName() - : SPD->getName(); - const std::string &MangledName = SPD->hasMangledName() ? SPD->getName() - : ""; + const std::string &Name = SPD->getName(); + const std::string &FullName = SPD->getFullName(); + const std::string &LinkageName = SPD->getLinkageName(); unsigned IsExternal = SPD->isStatic() ? 0 : 1; DIE *SubprogramDie = new DIE(DW_TAG_subprogram); AddString(SubprogramDie, DW_AT_name, DW_FORM_string, Name); - if (!MangledName.empty()) { + if (!LinkageName.empty()) { AddString(SubprogramDie, DW_AT_MIPS_linkage_name, DW_FORM_string, - MangledName); + LinkageName); } if (SPD->getType()) AddType(SubprogramDie, SPD->getType(), Unit); AddUInt(SubprogramDie, DW_AT_external, DW_FORM_flag, IsExternal); @@ -1830,7 +1825,7 @@ private: Unit->getDie()->AddChild(SubprogramDie); // Expose as global. - Unit->AddGlobal(Name, SubprogramDie); + Unit->AddGlobal(FullName, SubprogramDie); return SubprogramDie; } diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index 16f8dc8e20a..f6de1046fae 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -1048,7 +1048,8 @@ GlobalDesc::GlobalDesc(unsigned T) : AnchoredDesc(T) , Context(0) , Name("") -, DisplayName("") +, FullName("") +, LinkageName("") , File(NULL) , Line(0) , TyDesc(NULL) @@ -1063,7 +1064,8 @@ void GlobalDesc::ApplyToFields(DIVisitor *Visitor) { Visitor->Apply(Context); Visitor->Apply(Name); - if (getVersion() > LLVMDebugVersion4) Visitor->Apply(DisplayName); + Visitor->Apply(FullName); + Visitor->Apply(LinkageName); Visitor->Apply(File); Visitor->Apply(Line); Visitor->Apply(TyDesc); @@ -1117,7 +1119,8 @@ void GlobalVariableDesc::dump() { << "Tag(" << getTag() << "), " << "Anchor(" << getAnchor() << "), " << "Name(\"" << getName() << "\"), " - << "DisplayName(\"" << getDisplayName() << "\"), " + << "FullName(\"" << getFullName() << "\"), " + << "LinkageName(\"" << getLinkageName() << "\"), " << "File(" << getFile() << ")," << "Line(" << getLine() << ")," << "Type(" << getType() << "), " @@ -1170,7 +1173,8 @@ void SubprogramDesc::dump() { << "Tag(" << getTag() << "), " << "Anchor(" << getAnchor() << "), " << "Name(\"" << getName() << "\"), " - << "DisplayName(\"" << getDisplayName() << "\"), " + << "FullName(\"" << getFullName() << "\"), " + << "LinkageName(\"" << getLinkageName() << "\"), " << "File(" << getFile() << ")," << "Line(" << getLine() << ")," << "Type(" << getType() << "), "