[llvm] f1837c7 - [DebugInfo] Handle missed DW_FORM_addrx3 and DW_FORM_strx3 cases

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 06:46:00 PST 2023


Author: Benjamin Maxwell
Date: 2023-02-10T14:44:18Z
New Revision: f1837c7074788aa9b03046cb64496f62c0c8c361

URL: https://github.com/llvm/llvm-project/commit/f1837c7074788aa9b03046cb64496f62c0c8c361
DIFF: https://github.com/llvm/llvm-project/commit/f1837c7074788aa9b03046cb64496f62c0c8c361.diff

LOG: [DebugInfo] Handle missed DW_FORM_addrx3 and DW_FORM_strx3 cases

This fixes a few places where the addrx3 and strx3 forms were missed.
Previously this meant if one of these forms appeared somewhere various
errors could occur. This now also adds an extra test case for the addrx3
form (which previously failed).

Differential Revision: https://reviews.llvm.org/D143488

Added: 
    

Modified: 
    llvm/lib/BinaryFormat/Dwarf.cpp
    llvm/lib/CodeGen/AsmPrinter/DIE.cpp
    llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index fdf12a8ac993a..12e9c7374ce8f 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -737,6 +737,7 @@ std::optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
     return 2;
 
   case DW_FORM_strx3:
+  case DW_FORM_addrx3:
     return 3;
 
   case DW_FORM_data4:

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
index 308d4b1b5d610..583da5662a950 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -385,6 +385,7 @@ void DIEInteger::emitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
   case dwarf::DW_FORM_strx2:
   case dwarf::DW_FORM_addrx2:
   case dwarf::DW_FORM_strx3:
+  case dwarf::DW_FORM_addrx3:
   case dwarf::DW_FORM_strp:
   case dwarf::DW_FORM_ref4:
   case dwarf::DW_FORM_data4:

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index 1c26f1306b5e3..804b877291cea 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -160,9 +160,11 @@ bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
     case DW_FORM_ref_sup8:
     case DW_FORM_strx1:
     case DW_FORM_strx2:
+    case DW_FORM_strx3:
     case DW_FORM_strx4:
     case DW_FORM_addrx1:
     case DW_FORM_addrx2:
+    case DW_FORM_addrx3:
     case DW_FORM_addrx4:
     case DW_FORM_sec_offset:
     case DW_FORM_strp:
@@ -300,6 +302,7 @@ bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
       Value.uval = Data.getU16(OffsetPtr, &Err);
       break;
     case DW_FORM_strx3:
+    case DW_FORM_addrx3:
       Value.uval = Data.getU24(OffsetPtr, &Err);
       break;
     case DW_FORM_data4:

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 1db5f694c4c94..1d16a384d554a 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -51,6 +51,7 @@ void TestAllForms() {
   const AddrType AddrxValue = (AddrType)0x4231abcd4231abcdULL;
   const AddrType Addrx1Value = (AddrType)0x0000aaaabbbbccccULL;
   const AddrType Addrx2Value = (AddrType)0xf00123f00456f000ULL;
+  const AddrType Addrx3Value = (AddrType)0xABABA000B111C222ULL;
   const AddrType Addrx4Value = (AddrType)0xa1b2c3d4e5f6e5d4ULL;
 
   const uint8_t BlockData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
@@ -100,14 +101,14 @@ void TestAllForms() {
   const auto Attr_DW_FORM_addrx = static_cast<dwarf::Attribute>(Attr++);
   const auto Attr_DW_FORM_addrx1 = static_cast<dwarf::Attribute>(Attr++);
   const auto Attr_DW_FORM_addrx2 = static_cast<dwarf::Attribute>(Attr++);
-  // TODO: Add Attr_DW_FORM_addrx3 test (this form type is currently
-  // unsupported)
+  const auto Attr_DW_FORM_addrx3 = static_cast<dwarf::Attribute>(Attr++);
   const auto Attr_DW_FORM_addrx4 = static_cast<dwarf::Attribute>(Attr++);
 
   if (Version >= 5) {
     CUDie.addAttribute(Attr_DW_FORM_addrx, DW_FORM_addrx, AddrxValue);
     CUDie.addAttribute(Attr_DW_FORM_addrx1, DW_FORM_addrx1, Addrx1Value);
     CUDie.addAttribute(Attr_DW_FORM_addrx2, DW_FORM_addrx2, Addrx2Value);
+    CUDie.addAttribute(Attr_DW_FORM_addrx3, DW_FORM_addrx3, Addrx3Value);
     CUDie.addAttribute(Attr_DW_FORM_addrx4, DW_FORM_addrx4, Addrx4Value);
   }
 
@@ -275,6 +276,10 @@ void TestAllForms() {
     EXPECT_TRUE(ExtractedAddrx2Value.has_value());
     EXPECT_EQ(Addrx2Value, *ExtractedAddrx2Value);
 
+    auto ExtractedAddrx3Value = toAddress(DieDG.find(Attr_DW_FORM_addrx3));
+    EXPECT_TRUE(ExtractedAddrx3Value.has_value());
+    EXPECT_EQ(Addrx3Value, *ExtractedAddrx3Value);
+
     auto ExtractedAddrx4Value = toAddress(DieDG.find(Attr_DW_FORM_addrx4));
     EXPECT_TRUE(ExtractedAddrx1Value.has_value());
     EXPECT_EQ(Addrx4Value, *ExtractedAddrx4Value);

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
index 0d8913b964ad2..a7f272249f583 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
@@ -232,9 +232,11 @@ INSTANTIATE_TEST_SUITE_P(
         ParamType(DW_FORM_ref_sup8, 0, 0, DWARF32, SampleU32, 8, true),
         ParamType(DW_FORM_strx1, 0, 0, DWARF32, SampleU32, 1, true),
         ParamType(DW_FORM_strx2, 0, 0, DWARF32, SampleU32, 2, true),
+        ParamType(DW_FORM_strx3, 0, 0, DWARF32, SampleU32, 3, true),
         ParamType(DW_FORM_strx4, 0, 0, DWARF32, SampleU32, 4, true),
         ParamType(DW_FORM_addrx1, 0, 0, DWARF32, SampleU32, 1, true),
         ParamType(DW_FORM_addrx2, 0, 0, DWARF32, SampleU32, 2, true),
+        ParamType(DW_FORM_addrx3, 0, 0, DWARF32, SampleU32, 3, true),
         ParamType(DW_FORM_addrx4, 0, 0, DWARF32, SampleU32, 4, true),
         ParamType(DW_FORM_sec_offset, 0, 1, DWARF32, SampleU32, 0, false),
         ParamType(DW_FORM_sec_offset, 1, 0, DWARF32, SampleU32, 0, false),


        


More information about the llvm-commits mailing list