summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-05-24 16:40:47 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-05-24 16:40:47 +0000
commitf73bcf4020ff2f20e4ab50ed56258caaa590c5d6 (patch)
tree526cb98bdde33ade0e13308718bc956c30b8d6ce /llvm/lib/CodeGen/AsmPrinter
parent03b7a1cf93b215ce99cd4eadfba3b08f3242a4db (diff)
downloadbcm5719-llvm-f73bcf4020ff2f20e4ab50ed56258caaa590c5d6.tar.gz
bcm5719-llvm-f73bcf4020ff2f20e4ab50ed56258caaa590c5d6.zip
AsmPrinter: Make DIEString small
Expose the `DwarfStringPool` entry in a header, and store a pointer to it directly in `DIEString`. Instead of choosing at creation time how to emit it, use the `dwarf::Form` to determine that at emission time. Besides avoiding the other `DIEValue`, this shaves two pointers off of `DIEString`; the data is now a single pointer. This is a nice cleanup on its own -- and drops memory usage from 861 MB down to 853 MB, around 0.9% -- but it's also preparation for passing `DIEValue`s by value. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 238117
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DIE.cpp38
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp29
2 files changed, 38 insertions, 29 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
index c927bad4855..47f2dec018b 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -420,19 +420,49 @@ void DIEDelta::printImpl(raw_ostream &O) const {
/// EmitValue - Emit string value.
///
void DIEString::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
- Access->EmitValue(AP, Form);
+ assert(
+ (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
+ "Expected valid string form");
+
+ // Index of string in symbol table.
+ if (Form == dwarf::DW_FORM_GNU_str_index) {
+ DIEInteger(S.getIndex()).EmitValue(AP, Form);
+ return;
+ }
+
+ // Relocatable symbol.
+ assert(Form == dwarf::DW_FORM_strp);
+ if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) {
+ DIELabel(S.getSymbol()).EmitValue(AP, Form);
+ return;
+ }
+
+ // Offset into symbol table.
+ DIEInteger(S.getOffset()).EmitValue(AP, Form);
}
/// SizeOf - Determine size of delta value in bytes.
///
unsigned DIEString::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
- return Access->SizeOf(AP, Form);
+ assert(
+ (Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
+ "Expected valid string form");
+
+ // Index of string in symbol table.
+ if (Form == dwarf::DW_FORM_GNU_str_index)
+ return DIEInteger(S.getIndex()).SizeOf(AP, Form);
+
+ // Relocatable symbol.
+ if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
+ return DIELabel(S.getSymbol()).SizeOf(AP, Form);
+
+ // Offset into symbol table.
+ return DIEInteger(S.getOffset()).SizeOf(AP, Form);
}
#ifndef NDEBUG
void DIEString::printImpl(raw_ostream &O) const {
- O << "String: " << Str << "\tSymbol: ";
- Access->print(O);
+ O << "String: " << S.getString();
}
#endif
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 018d2b9918d..04836c61404 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -223,31 +223,10 @@ void DwarfUnit::addSInt(DIELoc &Die, Optional<dwarf::Form> Form,
void DwarfUnit::addString(DIE &Die, dwarf::Attribute Attribute,
StringRef String) {
- if (!isDwoUnit())
- return addLocalString(Die, Attribute, String);
-
- addIndexedString(Die, Attribute, String);
-}
-
-void DwarfUnit::addIndexedString(DIE &Die, dwarf::Attribute Attribute,
- StringRef String) {
- unsigned idx = DU->getStringPool().getIndex(*Asm, String);
- DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);
- DIEValue *Str = new (DIEValueAllocator) DIEString(Value, String);
- Die.addValue(Attribute, dwarf::DW_FORM_GNU_str_index, Str);
-}
-
-void DwarfUnit::addLocalString(DIE &Die, dwarf::Attribute Attribute,
- StringRef String) {
- DIEValue *Value;
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- Value = new (DIEValueAllocator)
- DIELabel(DU->getStringPool().getSymbol(*Asm, String));
- else
- Value = new (DIEValueAllocator)
- DIEInteger(DU->getStringPool().getOffset(*Asm, String));
- DIEValue *Str = new (DIEValueAllocator) DIEString(Value, String);
- Die.addValue(Attribute, dwarf::DW_FORM_strp, Str);
+ Die.addValue(Attribute,
+ isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp,
+ new (DIEValueAllocator)
+ DIEString(DU->getStringPool().getEntry(*Asm, String)));
}
void DwarfUnit::addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
OpenPOWER on IntegriCloud