Skip to content

Commit e0c46f8

Browse files
committed
[BOLT][NFC] Simplify BBHashMapTy
Make EntryTy a thin wrapper struct.
1 parent b910beb commit e0c46f8

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,9 @@ class BoltAddressTranslation {
178178
public:
179179
/// Map basic block input offset to a basic block index and hash pair.
180180
class BBHashMapTy {
181-
class EntryTy {
181+
struct EntryTy {
182182
unsigned Index;
183183
size_t Hash;
184-
185-
public:
186-
unsigned getBBIndex() const { return Index; }
187-
size_t getBBHash() const { return Hash; }
188-
EntryTy(unsigned Index, size_t Hash) : Index(Index), Hash(Hash) {}
189184
};
190185

191186
std::map<uint32_t, EntryTy> Map;
@@ -201,15 +196,15 @@ class BoltAddressTranslation {
201196
}
202197

203198
unsigned getBBIndex(uint32_t BBInputOffset) const {
204-
return getEntry(BBInputOffset).getBBIndex();
199+
return getEntry(BBInputOffset).Index;
205200
}
206201

207202
size_t getBBHash(uint32_t BBInputOffset) const {
208-
return getEntry(BBInputOffset).getBBHash();
203+
return getEntry(BBInputOffset).Hash;
209204
}
210205

211206
void addEntry(uint32_t BBInputOffset, unsigned BBIndex, size_t BBHash) {
212-
Map.emplace(BBInputOffset, EntryTy(BBIndex, BBHash));
207+
Map.emplace(BBInputOffset, EntryTy{BBIndex, BBHash});
213208
}
214209

215210
size_t getNumBasicBlocks() const { return Map.size(); }

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23522352
YamlBB.Index = Idx;
23532353

23542354
for (auto BI = BlockMap.begin(), BE = BlockMap.end(); BI != BE; ++BI)
2355-
YamlBF.Blocks[BI->second.getBBIndex()].Hash = BI->second.getBBHash();
2355+
YamlBF.Blocks[BI->second.Index].Hash = BI->second.Hash;
23562356

23572357
auto getSuccessorInfo = [&](uint32_t SuccOffset, unsigned SuccDataIdx) {
23582358
const llvm::bolt::BranchInfo &BI = Branches.Data.at(SuccDataIdx);
@@ -2392,7 +2392,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23922392
auto BlockIt = BlockMap.upper_bound(FromOffset);
23932393
--BlockIt;
23942394
const unsigned BlockOffset = BlockIt->first;
2395-
const unsigned BlockIndex = BlockIt->second.getBBIndex();
2395+
const unsigned BlockIndex = BlockIt->second.Index;
23962396
yaml::bolt::BinaryBasicBlockProfile &YamlBB = YamlBF.Blocks[BlockIndex];
23972397
const uint32_t Offset = FromOffset - BlockOffset;
23982398
for (const auto &[CallToLoc, CallToIdx] : CallTo)

0 commit comments

Comments
 (0)