Skip to content

Commit 78ef87f

Browse files
committed
[BOLT][NFC] Simplify BBHashMapTy
Make EntryTy a thin wrapper struct.
1 parent f203cb0 commit 78ef87f

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

196191
std::map<uint32_t, EntryTy> Map;
@@ -206,15 +201,15 @@ class BoltAddressTranslation {
206201
}
207202

208203
unsigned getBBIndex(uint32_t BBInputOffset) const {
209-
return getEntry(BBInputOffset).getBBIndex();
204+
return getEntry(BBInputOffset).Index;
210205
}
211206

212207
size_t getBBHash(uint32_t BBInputOffset) const {
213-
return getEntry(BBInputOffset).getBBHash();
208+
return getEntry(BBInputOffset).Hash;
214209
}
215210

216211
void addEntry(uint32_t BBInputOffset, unsigned BBIndex, size_t BBHash) {
217-
Map.emplace(BBInputOffset, EntryTy(BBIndex, BBHash));
212+
Map.emplace(BBInputOffset, EntryTy{BBIndex, BBHash});
218213
}
219214

220215
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
@@ -2355,7 +2355,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23552355
YamlBB.Index = Idx;
23562356

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

23602360
// Lookup containing basic block offset and index
23612361
auto getBlock = [&BlockMap](uint32_t Offset) {
@@ -2365,7 +2365,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23652365
exit(1);
23662366
}
23672367
--BlockIt;
2368-
return std::pair(BlockIt->first, BlockIt->second.getBBIndex());
2368+
return std::pair(BlockIt->first, BlockIt->second.Index);
23692369
};
23702370

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

0 commit comments

Comments
 (0)