Skip to content

[DWARF] Speedup .gdb_index dumping #151806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 7, 2025
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataExtractor.h"
Expand Down Expand Up @@ -60,6 +61,17 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
", filled slots:",
SymbolTableOffset, (uint64_t)SymbolTable.size())
<< '\n';

llvm::DenseMap<uint32_t, uint32_t> OffsetToIdMap(ConstantPoolVectors.size());
for (uint32_t Id = 0; Id < ConstantPoolVectors.size(); ++Id)
OffsetToIdMap[ConstantPoolVectors[Id].first] = Id;

const auto FindCuVectorId = [&](uint32_t VecOffset) {
const auto It = OffsetToIdMap.find(VecOffset);
assert(It != OffsetToIdMap.end() && "Invalid symbol table");
return It->second;
};

uint32_t I = -1;
for (const SymTableEntry &E : SymbolTable) {
++I;
Expand All @@ -72,13 +84,7 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
StringRef Name = ConstantPoolStrings.substr(
ConstantPoolOffset - StringPoolOffset + E.NameOffset);

auto CuVector = llvm::find_if(
ConstantPoolVectors,
[&](const std::pair<uint32_t, SmallVector<uint32_t, 0>> &V) {
return V.first == E.VecOffset;
});
assert(CuVector != ConstantPoolVectors.end() && "Invalid symbol table");
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin();
const uint32_t CuVectorId = FindCuVectorId(E.VecOffset);
OS << format(" String name: %s, CU vector index: %d\n", Name.data(),
CuVectorId);
}
Expand Down