From 21cd65acf4c95766193b9f6b2288dd1b8a8ffa3e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 2 Nov 2014 06:16:39 +0000 Subject: [PATCH] DebugInfo: Sink accelerator table lists down (GlobalNames/Types) into DwarfCompileUnit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221083 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 17 +++++++++++++++++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 15 +++++++++++++++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 8 +++++--- lib/CodeGen/AsmPrinter/DwarfDebug.h | 7 +++---- lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 16 ---------------- lib/CodeGen/AsmPrinter/DwarfUnit.h | 12 ++---------- 6 files changed, 42 insertions(+), 33 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index e670bb77515..d98b30e9b62 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -694,5 +694,22 @@ void DwarfCompileUnit::emitHeader(const MCSymbol *ASectionSym) const { DwarfUnit::emitHeader(ASectionSym); } +/// addGlobalName - Add a new global name to the compile unit. +void DwarfCompileUnit::addGlobalName(StringRef Name, DIE &Die, + DIScope Context) { + if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly) + return; + std::string FullName = getParentContextString(Context) + Name.str(); + GlobalNames[FullName] = &Die; +} + +/// Add a new global type to the unit. +void DwarfCompileUnit::addGlobalType(DIType Ty, const DIE &Die, + DIScope Context) { + if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly) + return; + std::string FullName = getParentContextString(Context) + Ty.getName().str(); + GlobalTypes[FullName] = &Die; +} } // end llvm namespace diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index 27ed6fc1431..043194ee246 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -42,6 +42,12 @@ class DwarfCompileUnit : public DwarfUnit { /// The start of the unit within its section. MCSymbol *LabelBegin; + /// GlobalNames - A map of globally visible named entities for this unit. + StringMap GlobalNames; + + /// GlobalTypes - A map of globally visible types for this unit. + StringMap GlobalTypes; + /// \brief Construct a DIE for the given DbgVariable without initializing the /// DbgVariable's DIE reference. std::unique_ptr constructVariableDIEImpl(const DbgVariable &DV, @@ -176,6 +182,15 @@ public: assert(Section); return LabelBegin; } + + /// Add a new global name to the compile unit. + void addGlobalName(StringRef Name, DIE &Die, DIScope Context) override; + + /// Add a new global type to the compile unit. + void addGlobalType(DIType Ty, const DIE &Die, DIScope Context) override; + + const StringMap &getGlobalNames() const { return GlobalNames; } + const StringMap &getGlobalTypes() const { return GlobalTypes; } }; } // end llvm namespace diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 5dbaa4d1f27..82b84e5247c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1562,12 +1562,13 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) { GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubNamesSection() : Asm->getObjFileLowering().getDwarfPubNamesSection(); - emitDebugPubSection(GnuStyle, PSec, "Names", &DwarfUnit::getGlobalNames); + emitDebugPubSection(GnuStyle, PSec, "Names", + &DwarfCompileUnit::getGlobalNames); } void DwarfDebug::emitDebugPubSection( bool GnuStyle, const MCSection *PSec, StringRef Name, - const StringMap &(DwarfUnit::*Accessor)() const) { + const StringMap &(DwarfCompileUnit::*Accessor)() const) { for (const auto &NU : CUMap) { DwarfCompileUnit *TheU = NU.second; @@ -1631,7 +1632,8 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) { GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubTypesSection() : Asm->getObjFileLowering().getDwarfPubTypesSection(); - emitDebugPubSection(GnuStyle, PSec, "Types", &DwarfUnit::getGlobalTypes); + emitDebugPubSection(GnuStyle, PSec, "Types", + &DwarfCompileUnit::getGlobalTypes); } // Emit visible names into a debug str section. diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 849580af7aa..fcd70c43c45 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -396,10 +396,9 @@ class DwarfDebug : public AsmPrinterHandler { /// index. void emitDebugPubTypes(bool GnuStyle = false); - void - emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name, - const StringMap &(DwarfUnit::*Accessor)() - const); + void emitDebugPubSection( + bool GnuStyle, const MCSection *PSec, StringRef Name, + const StringMap &(DwarfCompileUnit::*Accessor)() const); /// \brief Emit visible names into a debug str section. void emitDebugStr(); diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index e523bb007bb..e55b424c680 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1003,22 +1003,6 @@ void DwarfUnit::addType(DIE &Entity, DIType Ty, dwarf::Attribute Attribute) { addDIEEntry(Entity, Attribute, Entry); } -/// addGlobalName - Add a new global name to the compile unit. -void DwarfUnit::addGlobalName(StringRef Name, DIE &Die, DIScope Context) { - if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly) - return; - std::string FullName = getParentContextString(Context) + Name.str(); - GlobalNames[FullName] = &Die; -} - -/// Add a new global type to the unit. -void DwarfUnit::addGlobalType(DIType Ty, const DIE &Die, DIScope Context) { - if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly) - return; - std::string FullName = getParentContextString(Context) + Ty.getName().str(); - GlobalTypes[FullName] = &Die; -} - /// getParentContextString - Walks the metadata parent chain in a language /// specific manner (using the compile unit language) and returns /// it as a string. This is done at the metadata level because DIEs may diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h index fd3d6cb9ea6..e7e823f68df 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -96,12 +96,6 @@ protected: /// descriptors to debug information entries using a DIEEntry proxy. DenseMap MDNodeToDIEEntryMap; - /// GlobalNames - A map of globally visible named entities for this unit. - StringMap GlobalNames; - - /// GlobalTypes - A map of globally visible types for this unit. - StringMap GlobalTypes; - /// DIEBlocks - A list of all the DIEBlocks in use. std::vector DIEBlocks; @@ -146,8 +140,6 @@ public: uint16_t getLanguage() const { return CUNode.getLanguage(); } DICompileUnit getCUNode() const { return CUNode; } DIE &getUnitDie() { return UnitDie; } - const StringMap &getGlobalNames() const { return GlobalNames; } - const StringMap &getGlobalTypes() const { return GlobalTypes; } unsigned getDebugInfoOffset() const { return DebugInfoOffset; } void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; } @@ -175,10 +167,10 @@ public: std::string getParentContextString(DIScope Context) const; /// Add a new global name to the compile unit. - void addGlobalName(StringRef Name, DIE &Die, DIScope Context); + virtual void addGlobalName(StringRef Name, DIE &Die, DIScope Context) {} /// Add a new global type to the compile unit. - void addGlobalType(DIType Ty, const DIE &Die, DIScope Context); + virtual void addGlobalType(DIType Ty, const DIE &Die, DIScope Context) {} /// addAccelNamespace - Add a new name to the namespace accelerator table. void addAccelNamespace(StringRef Name, const DIE &Die); -- 2.34.1