From 3755781debe4a7feb6486f6d802813daa1b80dda Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sun, 24 May 2015 16:44:32 +0000 Subject: [PATCH] AsmPrinter: Use DwarfStringPoolEntry in DwarfAccelTable, NFC This is just an API change, but it prepares to stop using `EmitLabelDifference()` when possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238118 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/DwarfStringPoolEntry.h | 3 +++ lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp | 10 +++++----- lib/CodeGen/AsmPrinter/DwarfAccelTable.h | 6 ++---- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 12 ++++-------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/include/llvm/CodeGen/DwarfStringPoolEntry.h b/include/llvm/CodeGen/DwarfStringPoolEntry.h index 19fbbff0399..72ee66e97d7 100644 --- a/include/llvm/CodeGen/DwarfStringPoolEntry.h +++ b/include/llvm/CodeGen/DwarfStringPoolEntry.h @@ -38,6 +38,9 @@ public: unsigned getOffset() const { return I->second.Offset; } unsigned getIndex() const { return I->second.Index; } 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 diff --git a/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp b/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp index dfc61e69a88..ca953b982c2 100644 --- a/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp @@ -30,14 +30,14 @@ DwarfAccelTable::DwarfAccelTable(ArrayRef atomList) : Header(8 + (atomList.size() * 4)), HeaderData(atomList), Entries(Allocator) {} -void DwarfAccelTable::AddName(StringRef Name, MCSymbol *StrSym, const DIE *die, +void DwarfAccelTable::AddName(DwarfStringPoolEntryRef Name, const DIE *die, char Flags) { assert(Data.empty() && "Already finalized!"); // If the string is in the list already then add this die to the list // otherwise add a new one. - DataArray &DIEs = Entries[Name]; - assert(!DIEs.StrSym || DIEs.StrSym == StrSym); - DIEs.StrSym = StrSym; + DataArray &DIEs = Entries[Name.getString()]; + assert(!DIEs.Name || DIEs.Name == Name); + DIEs.Name = Name; 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. Asm->OutStreamer->EmitLabel((*HI)->Sym); Asm->OutStreamer->AddComment((*HI)->Str); - Asm->emitSectionOffset((*HI)->Data.StrSym); + Asm->emitSectionOffset((*HI)->Data.Name.getSymbol()); Asm->OutStreamer->AddComment("Num DIEs"); Asm->EmitInt32((*HI)->Data.Values.size()); for (HashDataContents *HD : (*HI)->Data.Values) { diff --git a/lib/CodeGen/AsmPrinter/DwarfAccelTable.h b/lib/CodeGen/AsmPrinter/DwarfAccelTable.h index e6fdf08b364..5745ecf9851 100644 --- a/lib/CodeGen/AsmPrinter/DwarfAccelTable.h +++ b/lib/CodeGen/AsmPrinter/DwarfAccelTable.h @@ -181,9 +181,8 @@ public: private: // String Data struct DataArray { - MCSymbol *StrSym; + DwarfStringPoolEntryRef Name; std::vector Values; - DataArray() : StrSym(nullptr) {} }; friend struct HashData; struct HashData { @@ -245,8 +244,7 @@ private: // Public Implementation public: DwarfAccelTable(ArrayRef); - void AddName(StringRef Name, MCSymbol *StrSym, const DIE *Die, - char Flags = 0); + void AddName(DwarfStringPoolEntryRef Name, const DIE *Die, char Flags = 0); void FinalizeTable(AsmPrinter *, StringRef); void emit(AsmPrinter *, const MCSymbol *, DwarfDebug *); #ifndef NDEBUG diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index bc2917d42b3..4e6a031f420 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1977,27 +1977,23 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, void DwarfDebug::addAccelName(StringRef Name, const DIE &Die) { if (!useDwarfAccelTables()) return; - AccelNames.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), - &Die); + AccelNames.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die); } void DwarfDebug::addAccelObjC(StringRef Name, const DIE &Die) { if (!useDwarfAccelTables()) return; - AccelObjC.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), - &Die); + AccelObjC.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die); } void DwarfDebug::addAccelNamespace(StringRef Name, const DIE &Die) { if (!useDwarfAccelTables()) return; - AccelNamespace.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), - &Die); + AccelNamespace.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die); } void DwarfDebug::addAccelType(StringRef Name, const DIE &Die, char Flags) { if (!useDwarfAccelTables()) return; - AccelTypes.AddName(Name, InfoHolder.getStringPool().getSymbol(*Asm, Name), - &Die); + AccelTypes.AddName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die); } -- 2.34.1