mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 06:25:18 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user