#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"
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"
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),
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;
// 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.
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);
+}
DwarfAccelTable AccelNames;
DwarfAccelTable AccelObjC;
DwarfAccelTable AccelNamespace;
+ DwarfAccelTable AccelTypes;
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
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
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()) &&
addDIEEntry(Entity, Attribute, Entry);
}
-void DwarfUnit::addAccelType(StringRef Name,
- std::pair<const DIE *, unsigned> Die) {
- if (!DD->useDwarfAccelTables())
- return;
- DU->getStringPoolEntry(Name);
- std::vector<std::pair<const DIE *, unsigned> > &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)
/// GlobalTypes - A map of globally visible types for this unit.
StringMap<const DIE *> GlobalTypes;
- /// AccelTypes - A map of names for the type accelerator table.
- StringMap<std::vector<std::pair<const DIE *, unsigned> > > AccelTypes;
-
/// DIEBlocks - A list of all the DIEBlocks in use.
std::vector<DIEBlock *> DIEBlocks;
const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
const StringMap<const DIE *> &getGlobalTypes() const { return GlobalTypes; }
- const StringMap<std::vector<std::pair<const DIE *, unsigned> > > &
- getAccelTypes() const {
- return AccelTypes;
- }
-
unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; }
/// 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<const DIE *, unsigned> 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