[PATCH] D87015: [DebugInfo] Use a common method to determine a suitable form for section offsts (8/19).

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 06:22:35 PDT 2020


ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhenderson, probinson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added a subscriber: hiraditya.
ikudrin requested review of this revision.

This is mostly an NFC patch because the involved methods are used when emitting DWO files, which is incompatible with DWARFv3, or for platforms where DWARF64 is not supported yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87015

Files:
  llvm/lib/CodeGen/AsmPrinter/DIE.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/unittests/CodeGen/DIETest.cpp


Index: llvm/unittests/CodeGen/DIETest.cpp
===================================================================
--- llvm/unittests/CodeGen/DIETest.cpp
+++ llvm/unittests/CodeGen/DIETest.cpp
@@ -162,8 +162,10 @@
     DIETestParams, DIEDeltaFixture,
     testing::Values(
         DIETestParams{4, dwarf::DWARF32, dwarf::DW_FORM_data4, 4u},
+        DIETestParams{4, dwarf::DWARF32, dwarf::DW_FORM_data8, 8u},
         DIETestParams{4, dwarf::DWARF32, dwarf::DW_FORM_sec_offset, 4u},
         DIETestParams{4, dwarf::DWARF64, dwarf::DW_FORM_data4, 4u},
+        DIETestParams{4, dwarf::DWARF64, dwarf::DW_FORM_data8, 8u},
         DIETestParams{4, dwarf::DWARF64, dwarf::DW_FORM_sec_offset, 8u}), );
 
 struct DIELocListFixture : public DIEFixtureBase {
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -300,10 +300,7 @@
 
 void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute,
                                  uint64_t Integer) {
-  if (DD->getDwarfVersion() >= 4)
-    addUInt(Die, Attribute, dwarf::DW_FORM_sec_offset, Integer);
-  else
-    addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
+  addUInt(Die, Attribute, DD->getDwarfSectionOffsetForm(), Integer);
 }
 
 unsigned DwarfTypeUnit::getOrCreateSourceID(const DIFile *File) {
@@ -1748,8 +1745,7 @@
 DwarfUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
                            const MCSymbol *Hi, const MCSymbol *Lo) {
   return Die.addValue(DIEValueAllocator, Attribute,
-                      DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
-                                                 : dwarf::DW_FORM_data4,
+                      DD->getDwarfSectionOffsetForm(),
                       new (DIEValueAllocator) DIEDelta(Hi, Lo));
 }
 
Index: llvm/lib/CodeGen/AsmPrinter/DIE.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -550,6 +550,8 @@
   switch (Form) {
   case dwarf::DW_FORM_data4:
     return 4;
+  case dwarf::DW_FORM_data8:
+    return 8;
   case dwarf::DW_FORM_sec_offset:
     return AP->isDwarf64() ? 8 : 4;
   default:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87015.289418.patch
Type: text/x-patch
Size: 2314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200902/2ca92430/attachment.bin>


More information about the llvm-commits mailing list