Skip to content

Commit 0d22a6f

Browse files
committed
[DWARF] Speedup .gdb_index dumping
1 parent af0be76 commit 0d22a6f

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <cinttypes>
1818
#include <cstdint>
1919
#include <set>
20+
#include <unordered_map>
2021
#include <utility>
2122

2223
using namespace llvm;
@@ -60,6 +61,24 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
6061
", filled slots:",
6162
SymbolTableOffset, (uint64_t)SymbolTable.size())
6263
<< '\n';
64+
65+
std::unordered_map<uint32_t, decltype(ConstantPoolVectors)::const_iterator>
66+
CuVectorMap{};
67+
CuVectorMap.reserve(ConstantPoolVectors.size());
68+
const auto FindCuVector =
69+
[&CuVectorMap, notFound = ConstantPoolVectors.end()](uint32_t vecOffset) {
70+
const auto it = CuVectorMap.find(vecOffset);
71+
if (it != CuVectorMap.end()) {
72+
return it->second;
73+
}
74+
75+
return notFound;
76+
};
77+
for (auto it = ConstantPoolVectors.begin(); it != ConstantPoolVectors.end();
78+
++it) {
79+
CuVectorMap.emplace(it->first, it);
80+
}
81+
6382
uint32_t I = -1;
6483
for (const SymTableEntry &E : SymbolTable) {
6584
++I;
@@ -72,11 +91,7 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
7291
StringRef Name = ConstantPoolStrings.substr(
7392
ConstantPoolOffset - StringPoolOffset + E.NameOffset);
7493

75-
auto CuVector = llvm::find_if(
76-
ConstantPoolVectors,
77-
[&](const std::pair<uint32_t, SmallVector<uint32_t, 0>> &V) {
78-
return V.first == E.VecOffset;
79-
});
94+
auto CuVector = FindCuVector(E.VecOffset);
8095
assert(CuVector != ConstantPoolVectors.end() && "Invalid symbol table");
8196
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin();
8297
OS << format(" String name: %s, CU vector index: %d\n", Name.data(),

0 commit comments

Comments
 (0)