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

@ -239,14 +239,13 @@ void DwarfUnit::addIndexedString(DIE &Die, dwarf::Attribute Attribute,
void DwarfUnit::addLocalString(DIE &Die, dwarf::Attribute Attribute,
StringRef String) {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
MCSymbol *Symb = DU->getStringPool().getSymbol(*Asm, String);
DIEValue *Value;
if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
Value = new (DIEValueAllocator) DIELabel(Symb);
Value = new (DIEValueAllocator)
DIELabel(DU->getStringPool().getSymbol(*Asm, String));
else
Value = new (DIEValueAllocator)
DIEDelta(Symb, TLOF.getDwarfStrSection()->getBeginSymbol());
DIEInteger(DU->getStringPool().getOffset(*Asm, String));
DIEValue *Str = new (DIEValueAllocator) DIEString(Value, String);
Die.addValue(Attribute, dwarf::DW_FORM_strp, Str);
}