mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
[BOLT][NFC] Simplify BBHashMapTy (#91812)
This commit is contained in:
@@ -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(); }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user