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" @@ -166,19 +167,20 @@ // for both a string and a CU vector. uint32_t SymTableSize = (ConstantPoolOffset - SymbolTableOffset) / 8; SymbolTable.reserve(SymTableSize); - uint32_t CuVectorsTotal = 0; + DenseSet CUIndeces; 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; + CUIndeces.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 (uint32_t I = 0, CuVectorsTotal = CUIndeces.size(); I < CuVectorsTotal; + ++I) { ConstantPoolVectors.emplace_back(0, SmallVector()); auto &Vec = ConstantPoolVectors.back(); Vec.first = Offset - ConstantPoolOffset;