diff options
author | Eric Christopher <echristo@gmail.com> | 2013-12-30 18:32:31 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2013-12-30 18:32:31 +0000 |
commit | 05893f475bc4db060a0b894837248d492783b8a1 (patch) | |
tree | 95688ff172fa3160e20d464d0d136aaac4c9e777 | |
parent | 9e3bc72b8d26b5e5e0a12c8f82705306bdae0e25 (diff) | |
download | bcm5719-llvm-05893f475bc4db060a0b894837248d492783b8a1.tar.gz bcm5719-llvm-05893f475bc4db060a0b894837248d492783b8a1.zip |
Refactor and reduce code duplication for non-split dwarf strings.
llvm-svn: 198233
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index e32582e76b1..f9611545f8f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/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. |