mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
Start splitting out the debug string section handling by moving it
into the DwarfUnits class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170770 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
55d8a35fb7
commit
2e5d870b38
@ -181,7 +181,7 @@ void DwarfAccelTable::EmitOffsets(AsmPrinter *Asm, MCSymbol *SecBegin) {
|
||||
// Walk through the buckets and emit the full data for each element in
|
||||
// the bucket. For the string case emit the dies and the various offsets.
|
||||
// Terminate each HashData bucket with 0.
|
||||
void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfDebug *D) {
|
||||
void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfUnits *D) {
|
||||
uint64_t PrevHash = UINT64_MAX;
|
||||
for (size_t i = 0, e = Buckets.size(); i < e; ++i) {
|
||||
for (HashList::const_iterator HI = Buckets[i].begin(),
|
||||
@ -190,7 +190,7 @@ void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfDebug *D) {
|
||||
Asm->OutStreamer.EmitLabel((*HI)->Sym);
|
||||
Asm->OutStreamer.AddComment((*HI)->Str);
|
||||
Asm->EmitSectionOffset(D->getStringPoolEntry((*HI)->Str),
|
||||
D->getStringPool());
|
||||
D->getStringPoolSym());
|
||||
Asm->OutStreamer.AddComment("Num DIEs");
|
||||
Asm->EmitInt32((*HI)->Data.size());
|
||||
for (ArrayRef<HashDataContents*>::const_iterator
|
||||
@ -215,7 +215,7 @@ void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfDebug *D) {
|
||||
|
||||
// Emit the entire data structure to the output file.
|
||||
void DwarfAccelTable::Emit(AsmPrinter *Asm, MCSymbol *SecBegin,
|
||||
DwarfDebug *D) {
|
||||
DwarfUnits *D) {
|
||||
// Emit the header.
|
||||
EmitHeader(Asm);
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace llvm {
|
||||
|
||||
class AsmPrinter;
|
||||
class DIE;
|
||||
class DwarfDebug;
|
||||
class DwarfUnits;
|
||||
|
||||
class DwarfAccelTable {
|
||||
|
||||
@ -245,7 +245,7 @@ private:
|
||||
void EmitBuckets(AsmPrinter *);
|
||||
void EmitHashes(AsmPrinter *);
|
||||
void EmitOffsets(AsmPrinter *, MCSymbol *);
|
||||
void EmitData(AsmPrinter *, DwarfDebug *D);
|
||||
void EmitData(AsmPrinter *, DwarfUnits *D);
|
||||
|
||||
// Allocator for HashData and HashDataContents.
|
||||
BumpPtrAllocator Allocator;
|
||||
@ -272,7 +272,7 @@ private:
|
||||
~DwarfAccelTable();
|
||||
void AddName(StringRef, DIE*, char = 0);
|
||||
void FinalizeTable(AsmPrinter *, const char *);
|
||||
void Emit(AsmPrinter *, MCSymbol *, DwarfDebug *);
|
||||
void Emit(AsmPrinter *, MCSymbol *, DwarfUnits *);
|
||||
#ifndef NDEBUG
|
||||
void print(raw_ostream &O);
|
||||
void dump() { print(dbgs()); }
|
||||
|
@ -33,8 +33,9 @@ using namespace llvm;
|
||||
|
||||
/// CompileUnit - Compile unit constructor.
|
||||
CompileUnit::CompileUnit(unsigned UID, unsigned L, DIE *D, AsmPrinter *A,
|
||||
DwarfDebug *DW)
|
||||
: UniqueID(UID), Language(L), CUDie(D), Asm(A), DD(DW), IndexTyDie(0) {
|
||||
DwarfDebug *DW, DwarfUnits *DWU)
|
||||
: UniqueID(UID), Language(L), CUDie(D), Asm(A), DD(DW), DU(DWU),
|
||||
IndexTyDie(0) {
|
||||
DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1);
|
||||
}
|
||||
|
||||
@ -127,12 +128,12 @@ void CompileUnit::addSInt(DIE *Die, unsigned Attribute,
|
||||
/// reference to the string pool instead of immediate strings so that DIEs have
|
||||
/// more predictable sizes.
|
||||
void CompileUnit::addString(DIE *Die, unsigned Attribute, StringRef String) {
|
||||
MCSymbol *Symb = DD->getStringPoolEntry(String);
|
||||
MCSymbol *Symb = DU->getStringPoolEntry(String);
|
||||
DIEValue *Value;
|
||||
if (Asm->needsRelocationsForDwarfStringPool())
|
||||
Value = new (DIEValueAllocator) DIELabel(Symb);
|
||||
else {
|
||||
MCSymbol *StringPool = DD->getStringPool();
|
||||
MCSymbol *StringPool = DU->getStringPoolSym();
|
||||
Value = new (DIEValueAllocator) DIEDelta(Symb, StringPool);
|
||||
}
|
||||
Die->addValue(Attribute, dwarf::DW_FORM_strp, Value);
|
||||
|
@ -23,6 +23,7 @@
|
||||
namespace llvm {
|
||||
|
||||
class DwarfDebug;
|
||||
class DwarfUnits;
|
||||
class MachineLocation;
|
||||
class MachineOperand;
|
||||
class ConstantInt;
|
||||
@ -47,7 +48,9 @@ class CompileUnit {
|
||||
/// Asm - Target of Dwarf emission.
|
||||
AsmPrinter *Asm;
|
||||
|
||||
// Holders for some common dwarf information.
|
||||
DwarfDebug *DD;
|
||||
DwarfUnits *DU;
|
||||
|
||||
/// IndexTyDie - An anonymous type for index type. Owned by CUDie.
|
||||
DIE *IndexTyDie;
|
||||
@ -84,7 +87,8 @@ class CompileUnit {
|
||||
int64_t getDefaultLowerBound() const;
|
||||
|
||||
public:
|
||||
CompileUnit(unsigned UID, unsigned L, DIE *D, AsmPrinter *A, DwarfDebug *DW);
|
||||
CompileUnit(unsigned UID, unsigned L, DIE *D, AsmPrinter *A, DwarfDebug *DW,
|
||||
DwarfUnits *);
|
||||
~CompileUnit();
|
||||
|
||||
// Accessors.
|
||||
|
@ -155,13 +155,12 @@ DIType DbgVariable::getType() const {
|
||||
DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
|
||||
: Asm(A), MMI(Asm->MMI), FirstCU(0),
|
||||
AbbreviationsSet(InitAbbreviationsSetSize),
|
||||
SourceIdMap(DIEValueAllocator), StringPool(DIEValueAllocator),
|
||||
SourceIdMap(DIEValueAllocator), InfoStringPool(DIEValueAllocator),
|
||||
PrevLabel(NULL), GlobalCUIndexCount(0),
|
||||
InfoHolder(A, &AbbreviationsSet, &Abbreviations),
|
||||
InfoHolder(A, &AbbreviationsSet, &Abbreviations, &InfoStringPool),
|
||||
SkeletonCU(0),
|
||||
SkeletonAbbrevSet(InitAbbreviationsSetSize),
|
||||
SkeletonHolder(A, &SkeletonAbbrevSet, &SkeletonAbbrevs) {
|
||||
NextStringPoolNumber = 0;
|
||||
SkeletonHolder(A, &SkeletonAbbrevSet, &SkeletonAbbrevs, &InfoStringPool) {
|
||||
|
||||
DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0;
|
||||
DwarfStrSectionSym = TextSectionSym = 0;
|
||||
@ -213,12 +212,13 @@ static MCSymbol *emitSectionSym(AsmPrinter *Asm, const MCSection *Section,
|
||||
return TmpSym;
|
||||
}
|
||||
|
||||
MCSymbol *DwarfDebug::getStringPool() {
|
||||
MCSymbol *DwarfUnits::getStringPoolSym() {
|
||||
return Asm->GetTempSymbol("section_str");
|
||||
}
|
||||
|
||||
MCSymbol *DwarfDebug::getStringPoolEntry(StringRef Str) {
|
||||
std::pair<MCSymbol*, unsigned> &Entry = StringPool[Str];
|
||||
MCSymbol *DwarfUnits::getStringPoolEntry(StringRef Str) {
|
||||
std::pair<MCSymbol*, unsigned> &Entry =
|
||||
StringPool->GetOrCreateValue(Str).getValue();
|
||||
if (Entry.first) return Entry.first;
|
||||
|
||||
Entry.second = NextStringPoolNumber++;
|
||||
@ -626,7 +626,8 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) {
|
||||
|
||||
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
|
||||
CompileUnit *NewCU = new CompileUnit(GlobalCUIndexCount++,
|
||||
DIUnit.getLanguage(), Die, Asm, this);
|
||||
DIUnit.getLanguage(), Die, Asm,
|
||||
this, &InfoHolder);
|
||||
NewCU->addString(Die, dwarf::DW_AT_producer, DIUnit.getProducer());
|
||||
NewCU->addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
|
||||
DIUnit.getLanguage());
|
||||
@ -1958,7 +1959,7 @@ void DwarfDebug::emitAccelNames() {
|
||||
Asm->OutStreamer.EmitLabel(SectionBegin);
|
||||
|
||||
// Emit the full data.
|
||||
AT.Emit(Asm, SectionBegin, this);
|
||||
AT.Emit(Asm, SectionBegin, &InfoHolder);
|
||||
}
|
||||
|
||||
// Emit objective C classes and categories into a hashed accelerator table section.
|
||||
@ -1986,7 +1987,7 @@ void DwarfDebug::emitAccelObjC() {
|
||||
Asm->OutStreamer.EmitLabel(SectionBegin);
|
||||
|
||||
// Emit the full data.
|
||||
AT.Emit(Asm, SectionBegin, this);
|
||||
AT.Emit(Asm, SectionBegin, &InfoHolder);
|
||||
}
|
||||
|
||||
// Emit namespace dies into a hashed accelerator table.
|
||||
@ -2014,7 +2015,7 @@ void DwarfDebug::emitAccelNamespaces() {
|
||||
Asm->OutStreamer.EmitLabel(SectionBegin);
|
||||
|
||||
// Emit the full data.
|
||||
AT.Emit(Asm, SectionBegin, this);
|
||||
AT.Emit(Asm, SectionBegin, &InfoHolder);
|
||||
}
|
||||
|
||||
// Emit type dies into a hashed accelerator table.
|
||||
@ -2049,7 +2050,7 @@ void DwarfDebug::emitAccelTypes() {
|
||||
Asm->OutStreamer.EmitLabel(SectionBegin);
|
||||
|
||||
// Emit the full data.
|
||||
AT.Emit(Asm, SectionBegin, this);
|
||||
AT.Emit(Asm, SectionBegin, &InfoHolder);
|
||||
}
|
||||
|
||||
void DwarfDebug::emitDebugPubTypes() {
|
||||
@ -2107,7 +2108,7 @@ void DwarfDebug::emitDebugPubTypes() {
|
||||
// Emit visible names into a debug str section.
|
||||
void DwarfDebug::emitDebugStr() {
|
||||
// Check to see if it is worth the effort.
|
||||
if (StringPool.empty()) return;
|
||||
if (InfoHolder.getStringPool()->empty()) return;
|
||||
|
||||
// Start the dwarf str section.
|
||||
Asm->OutStreamer.SwitchSection(
|
||||
@ -2119,7 +2120,7 @@ void DwarfDebug::emitDebugStr() {
|
||||
StringMapEntry<std::pair<MCSymbol*, unsigned> >*>, 64> Entries;
|
||||
|
||||
for (StringMap<std::pair<MCSymbol*, unsigned> >::iterator
|
||||
I = StringPool.begin(), E = StringPool.end(); I != E; ++I)
|
||||
I = InfoHolder.getStringPool()->begin(), E = InfoHolder.getStringPool()->end(); I != E; ++I)
|
||||
Entries.push_back(std::make_pair(I->second.second, &*I));
|
||||
|
||||
array_pod_sort(Entries.begin(), Entries.end());
|
||||
@ -2318,13 +2319,16 @@ void DwarfDebug::emitDebugInlineInfo() {
|
||||
|
||||
Asm->OutStreamer.AddComment("MIPS linkage name");
|
||||
if (LName.empty())
|
||||
Asm->EmitSectionOffset(getStringPoolEntry(Name), DwarfStrSectionSym);
|
||||
Asm->EmitSectionOffset(InfoHolder.getStringPoolEntry(Name),
|
||||
DwarfStrSectionSym);
|
||||
else
|
||||
Asm->EmitSectionOffset(getStringPoolEntry(getRealLinkageName(LName)),
|
||||
Asm->EmitSectionOffset(InfoHolder
|
||||
.getStringPoolEntry(getRealLinkageName(LName)),
|
||||
DwarfStrSectionSym);
|
||||
|
||||
Asm->OutStreamer.AddComment("Function name");
|
||||
Asm->EmitSectionOffset(getStringPoolEntry(Name), DwarfStrSectionSym);
|
||||
Asm->EmitSectionOffset(InfoHolder.getStringPoolEntry(Name),
|
||||
DwarfStrSectionSym);
|
||||
Asm->EmitULEB128(Labels.size(), "Inline count");
|
||||
|
||||
for (SmallVector<InlineInfoLabels, 4>::iterator LI = Labels.begin(),
|
||||
@ -2354,7 +2358,8 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const MDNode *N) {
|
||||
|
||||
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
|
||||
CompileUnit *NewCU = new CompileUnit(GlobalCUIndexCount++,
|
||||
DIUnit.getLanguage(), Die, Asm, this);
|
||||
DIUnit.getLanguage(), Die, Asm,
|
||||
this, &InfoHolder);
|
||||
// FIXME: This should be the .dwo file.
|
||||
NewCU->addString(Die, dwarf::DW_AT_GNU_dwo_name, FN);
|
||||
|
||||
|
@ -189,6 +189,12 @@ public:
|
||||
DIType getType() const;
|
||||
};
|
||||
|
||||
|
||||
// A String->Symbol mapping of strings used by indirect
|
||||
// references.
|
||||
typedef StringMap<std::pair<MCSymbol*, unsigned>,
|
||||
BumpPtrAllocator&> StrPool;
|
||||
|
||||
/// \brief Collects and handles information specific to a particular
|
||||
/// collection of units.
|
||||
class DwarfUnits {
|
||||
@ -204,10 +210,15 @@ class DwarfUnits {
|
||||
// A pointer to all units in the section.
|
||||
SmallVector<CompileUnit *, 1> CUs;
|
||||
|
||||
// Collection of strings for this unit.
|
||||
StrPool *StringPool;
|
||||
unsigned NextStringPoolNumber;
|
||||
|
||||
public:
|
||||
DwarfUnits(AsmPrinter *AP, FoldingSet<DIEAbbrev> *AS,
|
||||
std::vector<DIEAbbrev *> *A) :
|
||||
Asm(AP), AbbreviationsSet(AS), Abbreviations(A) {}
|
||||
std::vector<DIEAbbrev *> *A, StrPool *SP) :
|
||||
Asm(AP), AbbreviationsSet(AS), Abbreviations(A),
|
||||
StringPool(SP), NextStringPoolNumber(0) {}
|
||||
|
||||
/// \brief Compute the size and offset of a DIE given an incoming Offset.
|
||||
unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
|
||||
@ -225,6 +236,16 @@ public:
|
||||
/// abbreviation section.
|
||||
void emitUnits(DwarfDebug *, const MCSection *, const MCSection *,
|
||||
const MCSymbol *);
|
||||
|
||||
/// \brief Returns the entry into the start of the pool.
|
||||
MCSymbol *getStringPoolSym();
|
||||
|
||||
/// \brief Returns an entry into the string pool with the given
|
||||
/// string text.
|
||||
MCSymbol *getStringPoolEntry(StringRef Str);
|
||||
|
||||
/// \brief Returns the string pool.
|
||||
StrPool *getStringPool() { return StringPool; }
|
||||
};
|
||||
|
||||
/// \brief Collects and handles dwarf debug information.
|
||||
@ -262,8 +283,7 @@ class DwarfDebug {
|
||||
|
||||
// A String->Symbol mapping of strings used by indirect
|
||||
// references.
|
||||
StringMap<std::pair<MCSymbol*, unsigned>, BumpPtrAllocator&> StringPool;
|
||||
unsigned NextStringPoolNumber;
|
||||
StrPool InfoStringPool;
|
||||
|
||||
// Provides a unique id per text section.
|
||||
SetVector<const MCSection*> SectionMap;
|
||||
@ -579,13 +599,6 @@ public:
|
||||
/// SourceIds map.
|
||||
unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName);
|
||||
|
||||
/// \brief Returns the entry into the start of the pool.
|
||||
MCSymbol *getStringPool();
|
||||
|
||||
/// \brief Returns an entry into the string pool with the given
|
||||
/// string text.
|
||||
MCSymbol *getStringPoolEntry(StringRef Str);
|
||||
|
||||
/// \brief Recursively Emits a debug information entry.
|
||||
void emitDIE(DIE *Die, std::vector<DIEAbbrev *> *Abbrevs);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user