diff --git a/lib/CodeGen/AsmPrinter/DwarfAccelTable.h b/lib/CodeGen/AsmPrinter/DwarfAccelTable.h index 2ae2402a7a5..e7867db3c66 100644 --- a/lib/CodeGen/AsmPrinter/DwarfAccelTable.h +++ b/lib/CodeGen/AsmPrinter/DwarfAccelTable.h @@ -18,6 +18,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringMap.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" @@ -125,7 +126,8 @@ public: uint16_t type; // enum AtomType uint16_t form; // DWARF DW_FORM_ defines - Atom(uint16_t type, uint16_t form) : type(type), form(form) {} + LLVM_CONSTEXPR Atom(uint16_t type, uint16_t form) + : type(type), form(form) {} #ifndef NDEBUG void print(raw_ostream &O) { O << "Type: " << dwarf::AtomTypeString(type) << "\n" diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 5490721bc05..531c44cde4c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -164,6 +164,11 @@ DIType DbgVariable::getType() const { return Ty; } +static LLVM_CONSTEXPR DwarfAccelTable::Atom TypeAtoms[] = { + DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4), + DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2), + DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1)}; + DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) : Asm(A), MMI(Asm->MMI), FirstCU(0), PrevLabel(NULL), GlobalRangeCount(0), InfoHolder(A, "info_string", DIEValueAllocator), @@ -174,7 +179,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) AccelObjC(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4)), AccelNamespace(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, - dwarf::DW_FORM_data4)) { + dwarf::DW_FORM_data4)), + AccelTypes(TypeAtoms) { DwarfInfoSectionSym = DwarfAbbrevSectionSym = DwarfStrSectionSym = 0; DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = DwarfLineSectionSym = 0; @@ -1899,27 +1905,15 @@ void DwarfDebug::emitAccelNamespaces() { // Emit type dies into a hashed accelerator table. void DwarfDebug::emitAccelTypes() { - DwarfAccelTable::Atom Atoms[] = { - DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4), - DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2), - DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1)}; - DwarfAccelTable AT(Atoms); - for (const auto &TheU : getUnits()) { - for (const auto &GI : TheU->getAccelTypes()) { - StringRef Name = GI.getKey(); - for (const auto &DI : GI.second) - AT.AddName(Name, DI.first, DI.second); - } - } - AT.FinalizeTable(Asm, "types"); + AccelTypes.FinalizeTable(Asm, "types"); Asm->OutStreamer.SwitchSection( Asm->getObjFileLowering().getDwarfAccelTypesSection()); MCSymbol *SectionBegin = Asm->GetTempSymbol("types_begin"); Asm->OutStreamer.EmitLabel(SectionBegin); // Emit the full data. - AT.Emit(Asm, SectionBegin, &InfoHolder); + AccelTypes.Emit(Asm, SectionBegin, &InfoHolder); } // Public name handling. @@ -2567,3 +2561,10 @@ void DwarfDebug::addAccelNamespace(StringRef Name, const DIE *Die) { InfoHolder.getStringPoolEntry(Name); AccelNamespace.AddName(Name, Die); } + +void DwarfDebug::addAccelType(StringRef Name, const DIE *Die, char Flags) { + if (!useDwarfAccelTables()) + return; + InfoHolder.getStringPoolEntry(Name); + AccelTypes.AddName(Name, Die, Flags); +} diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index f3367f4cebe..02887b10fd0 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -327,6 +327,7 @@ class DwarfDebug : public AsmPrinterHandler { DwarfAccelTable AccelNames; DwarfAccelTable AccelObjC; DwarfAccelTable AccelNamespace; + DwarfAccelTable AccelTypes; MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); @@ -648,6 +649,8 @@ public: void addAccelObjC(StringRef Name, const DIE *Die); void addAccelNamespace(StringRef Name, const DIE *Die); + + void addAccelType(StringRef Name, const DIE *Die, char Flags); }; } // End of namespace llvm diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 9b5923441cd..333829e8a79 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1035,7 +1035,7 @@ void DwarfUnit::updateAcceleratorTables(DIScope Context, DIType Ty, IsImplementation = (CT.getRunTimeLang() == 0) || CT.isObjcClassComplete(); } unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0; - addAccelType(Ty.getName(), std::make_pair(TyDIE, Flags)); + DD->addAccelType(Ty.getName(), TyDIE, Flags); if ((!Context || Context.isCompileUnit() || Context.isFile() || Context.isNameSpace()) && @@ -1065,15 +1065,6 @@ void DwarfUnit::addType(DIE *Entity, DIType Ty, dwarf::Attribute Attribute) { addDIEEntry(Entity, Attribute, Entry); } -void DwarfUnit::addAccelType(StringRef Name, - std::pair Die) { - if (!DD->useDwarfAccelTables()) - return; - DU->getStringPoolEntry(Name); - std::vector > &DIEs = AccelTypes[Name]; - DIEs.push_back(Die); -} - /// addGlobalName - Add a new global name to the compile unit. void DwarfUnit::addGlobalName(StringRef Name, DIE *Die, DIScope Context) { if (getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly) diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h index 13fb1b5c9e2..c3c9660d473 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -102,9 +102,6 @@ protected: /// GlobalTypes - A map of globally visible types for this unit. StringMap GlobalTypes; - /// AccelTypes - A map of names for the type accelerator table. - StringMap > > AccelTypes; - /// DIEBlocks - A list of all the DIEBlocks in use. std::vector DIEBlocks; @@ -222,11 +219,6 @@ public: const StringMap &getGlobalNames() const { return GlobalNames; } const StringMap &getGlobalTypes() const { return GlobalTypes; } - const StringMap > > & - getAccelTypes() const { - return AccelTypes; - } - unsigned getDebugInfoOffset() const { return DebugInfoOffset; } void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; } @@ -260,9 +252,6 @@ public: /// addAccelNamespace - Add a new name to the namespace accelerator table. void addAccelNamespace(StringRef Name, const DIE *Die); - /// addAccelType - Add a new type to the type accelerator table. - void addAccelType(StringRef Name, std::pair Die); - /// getDIE - Returns the debug information entry map slot for the /// specified debug variable. We delegate the request to DwarfDebug /// when the MDNode can be part of the type system, since DIEs for