[BOLT][NFC] Simplify BBHashMapTy (#91812)

This commit is contained in:
Amir Ayupov
2024-05-22 16:00:51 -07:00
committed by GitHub
parent 7c937df05b
commit 465bfd41fa
2 changed files with 6 additions and 11 deletions

View File

@@ -184,14 +184,9 @@ private:
public:
/// Map basic block input offset to a basic block index and hash pair.
class BBHashMapTy {
class EntryTy {
struct EntryTy {
unsigned Index;
size_t Hash;
public:
unsigned getBBIndex() const { return Index; }
size_t getBBHash() const { return Hash; }
EntryTy(unsigned Index, size_t Hash) : Index(Index), Hash(Hash) {}
};
std::map<uint32_t, EntryTy> Map;
@@ -207,15 +202,15 @@ public:
}
unsigned getBBIndex(uint32_t BBInputOffset) const {
return getEntry(BBInputOffset).getBBIndex();
return getEntry(BBInputOffset).Index;
}
size_t getBBHash(uint32_t BBInputOffset) const {
return getEntry(BBInputOffset).getBBHash();
return getEntry(BBInputOffset).Hash;
}
void addEntry(uint32_t BBInputOffset, unsigned BBIndex, size_t BBHash) {
Map.emplace(BBInputOffset, EntryTy(BBIndex, BBHash));
Map.emplace(BBInputOffset, EntryTy{BBIndex, BBHash});
}
size_t getNumBasicBlocks() const { return Map.size(); }

View File

@@ -2353,7 +2353,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
YamlBB.Index = Idx;
for (auto BI = BlockMap.begin(), BE = BlockMap.end(); BI != BE; ++BI)
YamlBF.Blocks[BI->second.getBBIndex()].Hash = BI->second.getBBHash();
YamlBF.Blocks[BI->second.Index].Hash = BI->second.Hash;
// Lookup containing basic block offset and index
auto getBlock = [&BlockMap](uint32_t Offset) {
@@ -2363,7 +2363,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
exit(1);
}
--BlockIt;
return std::pair(BlockIt->first, BlockIt->second.getBBIndex());
return std::pair(BlockIt->first, BlockIt->second.Index);
};
for (const BranchInfo &BI : Branches.Data) {