Skip to content

Commit 465bfd4

Browse files
authored
[BOLT][NFC] Simplify BBHashMapTy (#91812)
1 parent 7c937df commit 465bfd4

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
@@ -184,14 +184,9 @@ class BoltAddressTranslation {
184184
public:
185185
/// Map basic block input offset to a basic block index and hash pair.
186186
class BBHashMapTy {
187-
class EntryTy {
187+
struct EntryTy {
188188
unsigned Index;
189189
size_t Hash;
190-
191-
public:
192-
unsigned getBBIndex() const { return Index; }
193-
size_t getBBHash() const { return Hash; }
194-
EntryTy(unsigned Index, size_t Hash) : Index(Index), Hash(Hash) {}
195190
};
196191

197192
std::map<uint32_t, EntryTy> Map;
@@ -207,15 +202,15 @@ class BoltAddressTranslation {
207202
}
208203

209204
unsigned getBBIndex(uint32_t BBInputOffset) const {
210-
return getEntry(BBInputOffset).getBBIndex();
205+
return getEntry(BBInputOffset).Index;
211206
}
212207

213208
size_t getBBHash(uint32_t BBInputOffset) const {
214-
return getEntry(BBInputOffset).getBBHash();
209+
return getEntry(BBInputOffset).Hash;
215210
}
216211

217212
void addEntry(uint32_t BBInputOffset, unsigned BBIndex, size_t BBHash) {
218-
Map.emplace(BBInputOffset, EntryTy(BBIndex, BBHash));
213+
Map.emplace(BBInputOffset, EntryTy{BBIndex, BBHash});
219214
}
220215

221216
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
@@ -2353,7 +2353,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23532353
YamlBB.Index = Idx;
23542354

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

23582358
// Lookup containing basic block offset and index
23592359
auto getBlock = [&BlockMap](uint32_t Offset) {
@@ -2363,7 +2363,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23632363
exit(1);
23642364
}
23652365
--BlockIt;
2366-
return std::pair(BlockIt->first, BlockIt->second.getBBIndex());
2366+
return std::pair(BlockIt->first, BlockIt->second.Index);
23672367
};
23682368

23692369
for (const BranchInfo &BI : Branches.Data) {

0 commit comments

Comments
 (0)