7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
10
+ #include < llvm/ADT/DenseMap.h>
10
11
#include " llvm/ADT/SmallVector.h"
11
12
#include " llvm/ADT/StringRef.h"
12
13
#include " llvm/Support/DataExtractor.h"
17
18
#include < cinttypes>
18
19
#include < cstdint>
19
20
#include < set>
20
- #include < unordered_map>
21
21
#include < utility>
22
22
23
23
using namespace llvm ;
@@ -62,22 +62,15 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
62
62
SymbolTableOffset, (uint64_t )SymbolTable.size ())
63
63
<< ' \n ' ;
64
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;
65
+ llvm::DenseMap<uint32_t , decltype (ConstantPoolVectors)::const_pointer>
66
+ CuVectorMap (ConstantPoolVectors.size ());
67
+ for (const auto & [Offset, CUVector] : ConstantPoolVectors)
68
+ CuVectorMap.try_emplace (Offset, &CUVector);
69
+
70
+ const auto FindCuVector =[&](uint32_t VecOffset) {
71
+ const auto It = CuVectorMap.find (VecOffset);
72
+ return It != CuVectorMap.end () ? It->second : ConstantPoolVectors.end ();
76
73
};
77
- for (auto it = ConstantPoolVectors.begin (); it != ConstantPoolVectors.end ();
78
- ++it) {
79
- CuVectorMap.emplace (it->first , it);
80
- }
81
74
82
75
uint32_t I = -1 ;
83
76
for (const SymTableEntry &E : SymbolTable) {
@@ -91,7 +84,7 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
91
84
StringRef Name = ConstantPoolStrings.substr (
92
85
ConstantPoolOffset - StringPoolOffset + E.NameOffset );
93
86
94
- auto CuVector = FindCuVector (E.VecOffset );
87
+ const auto * CuVector = FindCuVector (E.VecOffset );
95
88
assert (CuVector != ConstantPoolVectors.end () && " Invalid symbol table" );
96
89
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin ();
97
90
OS << format (" String name: %s, CU vector index: %d\n " , Name.data (),
0 commit comments