17
17
#include < cinttypes>
18
18
#include < cstdint>
19
19
#include < set>
20
+ #include < unordered_map>
20
21
#include < utility>
21
22
22
23
using namespace llvm ;
@@ -60,6 +61,24 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
60
61
" , filled slots:" ,
61
62
SymbolTableOffset, (uint64_t )SymbolTable.size ())
62
63
<< ' \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
+
63
82
uint32_t I = -1 ;
64
83
for (const SymTableEntry &E : SymbolTable) {
65
84
++I;
@@ -72,11 +91,7 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
72
91
StringRef Name = ConstantPoolStrings.substr (
73
92
ConstantPoolOffset - StringPoolOffset + E.NameOffset );
74
93
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 );
80
95
assert (CuVector != ConstantPoolVectors.end () && " Invalid symbol table" );
81
96
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin ();
82
97
OS << format (" String name: %s, CU vector index: %d\n " , Name.data (),
0 commit comments