Skip to content

Commit 069bf18

Browse files
authored
[DWARF] Speedup .gdb_index dumping (#151806)
This patch drastically speed ups dumping .gdb_index for large indexes
1 parent f68eedd commit 069bf18

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
6060
", filled slots:",
6161
SymbolTableOffset, (uint64_t)SymbolTable.size())
6262
<< '\n';
63+
64+
const auto FindCuVectorId = [&](uint32_t VecOffset) {
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();
75+
};
76+
6377
uint32_t I = -1;
6478
for (const SymTableEntry &E : SymbolTable) {
6579
++I;
@@ -72,13 +86,7 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
7286
StringRef Name = ConstantPoolStrings.substr(
7387
ConstantPoolOffset - StringPoolOffset + E.NameOffset);
7488

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-
});
80-
assert(CuVector != ConstantPoolVectors.end() && "Invalid symbol table");
81-
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin();
89+
const uint32_t CuVectorId = FindCuVectorId(E.VecOffset);
8290
OS << format(" String name: %s, CU vector index: %d\n", Name.data(),
8391
CuVectorId);
8492
}

0 commit comments

Comments
 (0)