|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
9 | 9 | #include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
|
10 |
| -#include "llvm/ADT/DenseMap.h" |
11 | 10 | #include "llvm/ADT/SmallVector.h"
|
12 | 11 | #include "llvm/ADT/StringRef.h"
|
13 | 12 | #include "llvm/Support/DataExtractor.h"
|
@@ -62,14 +61,17 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
|
62 | 61 | SymbolTableOffset, (uint64_t)SymbolTable.size())
|
63 | 62 | << '\n';
|
64 | 63 |
|
65 |
| - llvm::DenseMap<uint32_t, uint32_t> OffsetToIdMap(ConstantPoolVectors.size()); |
66 |
| - for (uint32_t Id = 0; Id < ConstantPoolVectors.size(); ++Id) |
67 |
| - OffsetToIdMap[ConstantPoolVectors[Id].first] = Id; |
68 |
| - |
69 | 64 | const auto FindCuVectorId = [&](uint32_t VecOffset) {
|
70 |
| - const auto It = OffsetToIdMap.find(VecOffset); |
71 |
| - assert(It != OffsetToIdMap.end() && "Invalid symbol table"); |
72 |
| - return It->second; |
| 65 | + // Entries in ConstantPoolVectors are sorted by their offset in constant |
| 66 | + // pool, see how ConstantPoolVectors is populated in parseImpl. |
| 67 | + const auto *It = |
| 68 | + llvm::lower_bound(ConstantPoolVectors, VecOffset, |
| 69 | + [](const auto &ConstantPoolEntry, uint32_t Offset) { |
| 70 | + return ConstantPoolEntry.first < Offset; |
| 71 | + }); |
| 72 | + assert(It != ConstantPoolVectors.end() && It->first == VecOffset && |
| 73 | + "Invalid symbol table"); |
| 74 | + return It - ConstantPoolVectors.begin(); |
73 | 75 | };
|
74 | 76 |
|
75 | 77 | uint32_t I = -1;
|
|
0 commit comments