[PATCH] D125611: DWARFVerifier: Change vector of IntervalMap to vector of unique_ptrs

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 14 11:17:04 PDT 2022


kparzysz created this revision.
kparzysz added reviewers: dblaikie, dim, brooks.
Herald added subscribers: hiraditya, krytarowski, arichardson, emaste.
Herald added a project: All.
kparzysz requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a workaround for compilation issue on FreeBSD. See comments in https://reviews.llvm.org/rG0d8cb8b399ad for more information.

This fixes https://github.com/llvm/llvm-project/issues/55414.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125611

Files:
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp


Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -406,9 +406,9 @@
   DataExtractor D(IndexStr, DCtx.isLittleEndian(), 0);
   if (!Index.parse(D))
     return 1;
-  IntervalMap<uint32_t, uint64_t>::Allocator Alloc;
-  std::vector<IntervalMap<uint32_t, uint64_t>> Sections(
-      Index.getColumnKinds().size(), IntervalMap<uint32_t, uint64_t>(Alloc));
+  using MapType = IntervalMap<uint32_t, uint64_t>;
+  MapType::Allocator Alloc;
+  std::vector<std::unique_ptr<MapType>> Sections(Index.getColumnKinds().size());
   for (const DWARFUnitIndex::Entry &E : Index.getRows()) {
     uint64_t Sig = E.getSignature();
     if (!E.getContributions())
@@ -421,16 +421,18 @@
       int Col = E.index();
       if (SC.Length == 0)
         continue;
+      if (!Sections[Col])
+        Sections[Col] = std::make_unique<MapType>(Alloc);
       auto &M = Sections[Col];
-      auto I = M.find(SC.Offset);
-      if (I != M.end() && I.start() < (SC.Offset + SC.Length)) {
+      auto I = M->find(SC.Offset);
+      if (I != M->end() && I.start() < (SC.Offset + SC.Length)) {
         error() << llvm::formatv(
             "overlapping index entries for entries {0:x16} "
             "and {1:x16} for column {2}\n",
             *I, Sig, toString(Index.getColumnKinds()[Col]));
         return 1;
       }
-      M.insert(SC.Offset, SC.Offset + SC.Length - 1, Sig);
+      M->insert(SC.Offset, SC.Offset + SC.Length - 1, Sig);
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125611.429468.patch
Type: text/x-patch
Size: 1595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220514/d19e1d60/attachment.bin>


More information about the llvm-commits mailing list