[PATCH] D146852: [DWARF][GDB INDEX] Fix to deal with constant pool de-dupliation Summary:

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 09:30:29 PDT 2023


ayermolo updated this revision to Diff 508699.
ayermolo added a comment.

updated to use offsets themselves


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146852

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


Index: llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DataExtractor.h"
@@ -16,6 +17,7 @@
 #include <cassert>
 #include <cinttypes>
 #include <cstdint>
+#include <set>
 #include <utility>
 
 using namespace llvm;
@@ -166,25 +168,26 @@
   // for both a string and a CU vector.
   uint32_t SymTableSize = (ConstantPoolOffset - SymbolTableOffset) / 8;
   SymbolTable.reserve(SymTableSize);
-  uint32_t CuVectorsTotal = 0;
+  std::set<uint32_t> CUOffsets;
   for (uint32_t i = 0; i < SymTableSize; ++i) {
     uint32_t NameOffset = Data.getU32(&Offset);
     uint32_t CuVecOffset = Data.getU32(&Offset);
     SymbolTable.push_back({NameOffset, CuVecOffset});
     if (NameOffset || CuVecOffset)
-      ++CuVectorsTotal;
+      CUOffsets.insert(CuVecOffset);
   }
 
   // The constant pool. CU vectors are stored first, followed by strings.
   // The first value is the number of CU indices in the vector. Each subsequent
   // value is the index and symbol attributes of a CU in the CU list.
-  for (uint32_t i = 0; i < CuVectorsTotal; ++i) {
+  for (auto CUOffset : CUOffsets) {
+    Offset = ConstantPoolOffset + CUOffset;
     ConstantPoolVectors.emplace_back(0, SmallVector<uint32_t, 0>());
     auto &Vec = ConstantPoolVectors.back();
     Vec.first = Offset - ConstantPoolOffset;
 
     uint32_t Num = Data.getU32(&Offset);
-    for (uint32_t j = 0; j < Num; ++j)
+    for (uint32_t J = 0; J < Num; ++J)
       Vec.second.push_back(Data.getU32(&Offset));
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146852.508699.patch
Type: text/x-patch
Size: 1894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230327/fdb7fdf6/attachment.bin>


More information about the llvm-commits mailing list