diff --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ b/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 #include #include +#include #include 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 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()); 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)); }