Skip to content

Commit 4d30a5c

Browse files
committed
cr fixes
1 parent 0d22a6f commit 4d30a5c

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
10+
#include <llvm/ADT/DenseMap.h>
1011
#include "llvm/ADT/SmallVector.h"
1112
#include "llvm/ADT/StringRef.h"
1213
#include "llvm/Support/DataExtractor.h"
@@ -17,7 +18,6 @@
1718
#include <cinttypes>
1819
#include <cstdint>
1920
#include <set>
20-
#include <unordered_map>
2121
#include <utility>
2222

2323
using namespace llvm;
@@ -62,22 +62,15 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
6262
SymbolTableOffset, (uint64_t)SymbolTable.size())
6363
<< '\n';
6464

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();
7673
};
77-
for (auto it = ConstantPoolVectors.begin(); it != ConstantPoolVectors.end();
78-
++it) {
79-
CuVectorMap.emplace(it->first, it);
80-
}
8174

8275
uint32_t I = -1;
8376
for (const SymTableEntry &E : SymbolTable) {
@@ -91,7 +84,7 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
9184
StringRef Name = ConstantPoolStrings.substr(
9285
ConstantPoolOffset - StringPoolOffset + E.NameOffset);
9386

94-
auto CuVector = FindCuVector(E.VecOffset);
87+
const auto* CuVector = FindCuVector(E.VecOffset);
9588
assert(CuVector != ConstantPoolVectors.end() && "Invalid symbol table");
9689
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin();
9790
OS << format(" String name: %s, CU vector index: %d\n", Name.data(),

0 commit comments

Comments
 (0)