AsmPrinter: Use DwarfStringPoolEntry in DwarfAccelTable, NFC
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DIE.cpp
index dca85c73f00157af4bb1c8404f0c9f4e81bd340e..47f2dec018be9b4f7e508cd03480892656a45479 100644 (file)
@@ -228,6 +228,7 @@ unsigned DIEValue::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
     SIZE_OF_IMPL(LocList)
 #undef SIZE_OF_IMPL
   }
+  llvm_unreachable("Unknown DIE kind");
 }
 
 #ifndef NDEBUG
@@ -419,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