-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[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
Changes from 1 commit
0d22a6f
4d30a5c
72ff5d8
9601b2f
b51c223
ab33820
6abe831
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
#include <cinttypes> | ||
#include <cstdint> | ||
#include <set> | ||
#include <unordered_map> | ||
#include <utility> | ||
|
||
using namespace llvm; | ||
|
@@ -60,6 +61,24 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const { | |
", filled slots:", | ||
SymbolTableOffset, (uint64_t)SymbolTable.size()) | ||
<< '\n'; | ||
|
||
std::unordered_map<uint32_t, decltype(ConstantPoolVectors)::const_iterator> | ||
CuVectorMap{}; | ||
itrofimow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CuVectorMap.reserve(ConstantPoolVectors.size()); | ||
const auto FindCuVector = | ||
[&CuVectorMap, notFound = ConstantPoolVectors.end()](uint32_t vecOffset) { | ||
itrofimow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const auto it = CuVectorMap.find(vecOffset); | ||
if (it != CuVectorMap.end()) { | ||
return it->second; | ||
} | ||
itrofimow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return notFound; | ||
}; | ||
for (auto it = ConstantPoolVectors.begin(); it != ConstantPoolVectors.end(); | ||
++it) { | ||
CuVectorMap.emplace(it->first, it); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could drop the Could use a range-based for loop, and instead of putting iterators as values in the map, use pointers (then you can get a pointer to the value in the range based for loop where there aren't any visible/name-able iterators) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've rearranged the code a bit to just hold the ids in the map, instead of calculating these ids later |
||
|
||
uint32_t I = -1; | ||
for (const SymTableEntry &E : SymbolTable) { | ||
++I; | ||
|
@@ -72,11 +91,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; | ||
}); | ||
auto CuVector = FindCuVector(E.VecOffset); | ||
assert(CuVector != ConstantPoolVectors.end() && "Invalid symbol table"); | ||
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin(); | ||
OS << format(" String name: %s, CU vector index: %d\n", Name.data(), | ||
|
Uh oh!
There was an error while loading. Please reload this page.