AsmPrinter: Emit the DwarfStringPool offset directly when possible

Change `DwarfStringPool` to calculate byte offsets on-the-fly, and
update `DwarfUnit::getLocalString()` to use a `DIEInteger` instead of a
`DIEDelta` when Dwarf doesn't use relocations (i.e., Mach-O).  This
eliminates another call to `EmitLabelDifference()`, and drops memory
usage from 865 MB down to 861 MB, around 0.5%.

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238114 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-05-24 16:14:59 +00:00
parent 237137532a
commit e3ae958f94
5 changed files with 39 additions and 28 deletions

View File

@@ -25,8 +25,14 @@ class StringRef;
// A String->Symbol mapping of strings used by indirect
// references.
class DwarfStringPool {
StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> Pool;
struct EntryTy {
MCSymbol *Symbol;
unsigned Offset;
unsigned Index;
};
StringMap<EntryTy, BumpPtrAllocator &> Pool;
StringRef Prefix;
unsigned NumBytes = 0;
public:
DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
@@ -38,19 +44,24 @@ public:
/// \brief Returns an entry into the string pool with the given
/// string text.
MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str) {
return getEntry(Asm, Str).first;
return getEntry(Asm, Str).Symbol;
}
/// Get a byte offset into the string pool with the given text.
unsigned getOffset(AsmPrinter &Asm, StringRef Str) {
return getEntry(Asm, Str).Offset;
}
/// \brief Returns the index into the string pool with the given
/// string text.
unsigned getIndex(AsmPrinter &Asm, StringRef Str) {
return getEntry(Asm, Str).second;
return getEntry(Asm, Str).Index;
}
bool empty() const { return Pool.empty(); }
private:
std::pair<MCSymbol *, unsigned> &getEntry(AsmPrinter &Asm, StringRef Str);
EntryTy &getEntry(AsmPrinter &Asm, StringRef Str);
};
}
#endif