AsmPrinter: Use DwarfStringPoolEntry in DwarfAccelTable, NFC

This is just an API change, but it prepares to stop using
`EmitLabelDifference()` when possible.

llvm-svn: 238118
This commit is contained in:
Duncan P. N. Exon Smith 2015-05-24 16:44:32 +00:00
parent f73bcf4020
commit f4599942fb
4 changed files with 14 additions and 17 deletions

View File

@ -38,6 +38,9 @@ public:
unsigned getOffset() const { return I->second.Offset; } unsigned getOffset() const { return I->second.Offset; }
unsigned getIndex() const { return I->second.Index; } unsigned getIndex() const { return I->second.Index; }
StringRef getString() const { return I->first(); } StringRef getString() const { return I->first(); }
bool operator==(const DwarfStringPoolEntryRef &X) const { return I == X.I; }
bool operator!=(const DwarfStringPoolEntryRef &X) const { return I != X.I; }
}; };
} // end namespace llvm } // end namespace llvm

View File

@ -30,14 +30,14 @@ DwarfAccelTable::DwarfAccelTable(ArrayRef<DwarfAccelTable::Atom> atomList)
: Header(8 + (atomList.size() * 4)), HeaderData(atomList), : Header(8 + (atomList.size() * 4)), HeaderData(atomList),
Entries(Allocator) {} Entries(Allocator) {}
void DwarfAccelTable::AddName(StringRef Name, MCSymbol *StrSym, const DIE *die, void DwarfAccelTable::AddName(DwarfStringPoolEntryRef Name, const DIE *die,
char Flags) { char Flags) {
assert(Data.empty() && "Already finalized!"); assert(Data.empty() && "Already finalized!");
// If the string is in the list already then add this die to the list // If the string is in the list already then add this die to the list
// otherwise add a new one. // otherwise add a new one.
DataArray &DIEs = Entries[Name]; DataArray &DIEs = Entries[Name.getString()];
assert(!DIEs.StrSym || DIEs.StrSym == StrSym); assert(!DIEs.Name || DIEs.Name == Name);
DIEs.StrSym = StrSym; DIEs.Name = Name;
DIEs.Values.push_back(new (Allocator) HashDataContents(die, Flags)); DIEs.Values.push_back(new (Allocator) HashDataContents(die, Flags));
} }
@ -216,7 +216,7 @@ void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfDebug *D) {
// Remember to emit the label for our offset. // Remember to emit the label for our offset.
Asm->OutStreamer->EmitLabel((*HI)->Sym); Asm->OutStreamer->EmitLabel((*HI)->Sym);
Asm->OutStreamer->AddComment((*HI)->Str); Asm->OutStreamer->AddComment((*HI)->Str);
Asm->emitSectionOffset((*HI)->Data.StrSym); Asm->emitSectionOffset((*HI)->Data.Name.getSymbol());
Asm->OutStreamer->AddComment("Num DIEs"); Asm->OutStreamer->AddComment("Num DIEs");
Asm->EmitInt32((*HI)->Data.Values.size()); Asm->EmitInt32((*HI)->Data.Values.size());
for (HashDataContents *HD : (*HI)->Data.Values) { for (HashDataContents *HD : (*HI)->Data.Values) {

View File

@ -181,9 +181,8 @@ public:
private: private:
// String Data // String Data
struct DataArray { struct DataArray {
MCSymbol *StrSym; DwarfStringPoolEntryRef Name;
std::vector<HashDataContents *> Values; std::vector<HashDataContents *> Values;
DataArray() : StrSym(nullptr) {}
}; };
friend struct HashData; friend struct HashData;
struct HashData { struct HashData {
@ -245,8 +244,7 @@ private:
// Public Implementation // Public Implementation
public: public:
DwarfAccelTable(ArrayRef<DwarfAccelTable::Atom>); DwarfAccelTable(ArrayRef<DwarfAccelTable::Atom>);
void AddName(StringRef Name, MCSymbol *StrSym, const DIE *Die, void AddName(DwarfStringPoolEntryRef Name, const DIE *Die, char Flags = 0);
char Flags = 0);
void FinalizeTable(AsmPrinter *, StringRef); void FinalizeTable(AsmPrinter *, StringRef);
void emit(AsmPrinter *, const MCSymbol *, DwarfDebug *); void emit(AsmPrinter *, const MCSymbol *, DwarfDebug *);
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -1977,27 +1977,23 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
void DwarfDebug::addAccelName(StringRef Name, const DIE &Die) { void DwarfDebug::addAccelName(StringRef Name, const DIE &Die) {
if (!useDwarfAccelTables()) if (!useDwarfAccelTables())
return; return;
AccelNames.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), AccelNames.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
&Die);
} }
void DwarfDebug::addAccelObjC(StringRef Name, const DIE &Die) { void DwarfDebug::addAccelObjC(StringRef Name, const DIE &Die) {
if (!useDwarfAccelTables()) if (!useDwarfAccelTables())
return; return;
AccelObjC.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), AccelObjC.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
&Die);
} }
void DwarfDebug::addAccelNamespace(StringRef Name, const DIE &Die) { void DwarfDebug::addAccelNamespace(StringRef Name, const DIE &Die) {
if (!useDwarfAccelTables()) if (!useDwarfAccelTables())
return; return;
AccelNamespace.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), AccelNamespace.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
&Die);
} }
void DwarfDebug::addAccelType(StringRef Name, const DIE &Die, char Flags) { void DwarfDebug::addAccelType(StringRef Name, const DIE &Die, char Flags) {
if (!useDwarfAccelTables()) if (!useDwarfAccelTables())
return; return;
AccelTypes.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), AccelTypes.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
&Die);
} }