summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-12-30 18:32:31 +0000
committerEric Christopher <echristo@gmail.com>2013-12-30 18:32:31 +0000
commit98b356bc64d73fefd10e130e76d042ba84411e17 (patch)
tree06912b4d390185b896d956fe0a5216c9ae2c3440 /lib/CodeGen/AsmPrinter/DwarfUnit.cpp
parentd7109840cdb5dc0caef3a561e5f36a24844bd1d0 (diff)
downloadllvm-98b356bc64d73fefd10e130e76d042ba84411e17.tar.gz
llvm-98b356bc64d73fefd10e130e76d042ba84411e17.tar.bz2
llvm-98b356bc64d73fefd10e130e76d042ba84411e17.tar.xz
Refactor and reduce code duplication for non-split dwarf strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198233 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfUnit.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index e32582e76b..f9611545f8 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -195,24 +195,14 @@ void DwarfUnit::addSInt(DIEBlock *Die, Optional<dwarf::Form> Form,
/// table.
void DwarfUnit::addString(DIE *Die, dwarf::Attribute Attribute,
StringRef String) {
- DIEValue *Value;
- dwarf::Form Form;
- if (!DD->useSplitDwarf()) {
- MCSymbol *Symb = DU->getStringPoolEntry(String);
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- Value = new (DIEValueAllocator) DIELabel(Symb);
- else {
- MCSymbol *StringPool = DU->getStringPoolSym();
- Value = new (DIEValueAllocator) DIEDelta(Symb, StringPool);
- }
- Form = dwarf::DW_FORM_strp;
- } else {
- unsigned idx = DU->getStringPoolIndex(String);
- Value = new (DIEValueAllocator) DIEInteger(idx);
- Form = dwarf::DW_FORM_GNU_str_index;
- }
+
+ if (!DD->useSplitDwarf())
+ return addLocalString(Die, Attribute, String);
+
+ unsigned idx = DU->getStringPoolIndex(String);
+ DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);
DIEValue *Str = new (DIEValueAllocator) DIEString(Value, String);
- Die->addValue(Attribute, Form, Str);
+ Die->addValue(Attribute, dwarf::DW_FORM_GNU_str_index, Str);
}
/// addLocalString - Add a string attribute data and value. This is guaranteed
@@ -227,7 +217,8 @@ void DwarfUnit::addLocalString(DIE *Die, dwarf::Attribute Attribute,
MCSymbol *StringPool = DU->getStringPoolSym();
Value = new (DIEValueAllocator) DIEDelta(Symb, StringPool);
}
- Die->addValue(Attribute, dwarf::DW_FORM_strp, Value);
+ DIEValue *Str = new (DIEValueAllocator) DIEString(Value, String);
+ Die->addValue(Attribute, dwarf::DW_FORM_strp, Str);
}
/// addExpr - Add a Dwarf expression attribute data and value.