[llvm] [BOLT][NFC] Simplify BBHashMapTy (PR #91812)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 10 14:19:17 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Amir Ayupov (aaupov)
<details>
<summary>Changes</summary>
Make EntryTy a thin wrapper struct.
---
Full diff: https://github.com/llvm/llvm-project/pull/91812.diff
2 Files Affected:
- (modified) bolt/include/bolt/Profile/BoltAddressTranslation.h (+4-9)
- (modified) bolt/lib/Profile/DataAggregator.cpp (+2-2)
``````````diff
diff --git a/bolt/include/bolt/Profile/BoltAddressTranslation.h b/bolt/include/bolt/Profile/BoltAddressTranslation.h
index 68b993ee363cc..6f14390313efe 100644
--- a/bolt/include/bolt/Profile/BoltAddressTranslation.h
+++ b/bolt/include/bolt/Profile/BoltAddressTranslation.h
@@ -178,14 +178,9 @@ class BoltAddressTranslation {
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;
@@ -201,15 +196,15 @@ class BoltAddressTranslation {
}
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(); }
diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index d02e4499014ed..49e7ecce9d2d2 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -2352,7 +2352,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;
auto getSuccessorInfo = [&](uint32_t SuccOffset, unsigned SuccDataIdx) {
const llvm::bolt::BranchInfo &BI = Branches.Data.at(SuccDataIdx);
@@ -2392,7 +2392,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
auto BlockIt = BlockMap.upper_bound(FromOffset);
--BlockIt;
const unsigned BlockOffset = BlockIt->first;
- const unsigned BlockIndex = BlockIt->second.getBBIndex();
+ const unsigned BlockIndex = BlockIt->second.Index;
yaml::bolt::BinaryBasicBlockProfile &YamlBB = YamlBF.Blocks[BlockIndex];
const uint32_t Offset = FromOffset - BlockOffset;
for (const auto &[CallToLoc, CallToIdx] : CallTo)
``````````
</details>
https://github.com/llvm/llvm-project/pull/91812
More information about the llvm-commits
mailing list