[PATCH] D154655: [DebugInfo] Force users of DWARFDebugAbbrev to call parse before iterating

Alex Langford via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 15:14:09 PDT 2023


bulbazord updated this revision to Diff 538847.
bulbazord added a comment.
Herald added a reviewer: rafauler.
Herald added subscribers: yota9, ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.

Fix bolt test failures


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154655/new/

https://reviews.llvm.org/D154655

Files:
  bolt/lib/Core/DebugData.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
  llvm/tools/obj2yaml/dwarf2yaml.cpp


Index: llvm/tools/obj2yaml/dwarf2yaml.cpp
===================================================================
--- llvm/tools/obj2yaml/dwarf2yaml.cpp
+++ llvm/tools/obj2yaml/dwarf2yaml.cpp
@@ -26,6 +26,7 @@
   auto AbbrevSetPtr = DCtx.getDebugAbbrev();
   if (AbbrevSetPtr) {
     uint64_t AbbrevTableID = 0;
+    AbbrevSetPtr->parse();
     for (auto AbbrvDeclSet : *AbbrevSetPtr) {
       Y.DebugAbbrev.emplace_back();
       Y.DebugAbbrev.back().ID = AbbrevTableID++;
@@ -219,6 +220,7 @@
     if (NewUnit.Version >= 5)
       NewUnit.Type = (dwarf::UnitType)CU->getUnitType();
     const DWARFDebugAbbrev *DebugAbbrev = DCtx.getDebugAbbrev();
+    DebugAbbrev->parse();
     NewUnit.AbbrevTableID = std::distance(
         DebugAbbrev->begin(),
         llvm::find_if(
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
@@ -73,7 +73,7 @@
   void parse() const;
 
   DWARFAbbreviationDeclarationSetMap::const_iterator begin() const {
-    parse();
+    assert(!Data && "Must call parse before iterating over DWARFDebugAbbrev");
     return AbbrDeclSets.begin();
   }
 
Index: bolt/lib/Core/DebugData.cpp
===================================================================
--- bolt/lib/Core/DebugData.cpp
+++ bolt/lib/Core/DebugData.cpp
@@ -1298,8 +1298,11 @@
       // FIXME: if we had a full access to DWARFDebugAbbrev::AbbrDeclSets
       // we wouldn't have to build our own sorted list for the quick lookup.
       if (AbbrevSetOffsets.empty()) {
+        const DWARFDebugAbbrev *DebugAbbrev =
+            Unit.getContext().getDebugAbbrev();
+        DebugAbbrev->parse();
         for (const std::pair<const uint64_t, DWARFAbbreviationDeclarationSet>
-                 &P : *Unit.getContext().getDebugAbbrev())
+                 &P : *DebugAbbrev)
           AbbrevSetOffsets.push_back(P.first);
         sort(AbbrevSetOffsets);
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154655.538847.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230710/7667535b/attachment.bin>


More information about the llvm-commits mailing list