Skip to content

[BOLT][NFC] Simplify BBHashMapTy #91812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged

[BOLT][NFC] Simplify BBHashMapTy #91812

merged 1 commit into from
May 22, 2024

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented May 10, 2024

Make EntryTy a thin wrapper struct.

@llvmbot
Copy link
Member

llvmbot commented May 10, 2024

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

Changes

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 --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)

Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #91815. This doesn't seem to me it improves things significantly, and again deferring to @maksfb or @rafaelauler.

Copy link
Contributor

@rafaelauler rafaelauler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

Make EntryTy a thin wrapper struct.
@aaupov aaupov force-pushed the simplify-ctc-bat branch from e0c46f8 to 78ef87f Compare May 22, 2024 21:25
@aaupov aaupov merged commit 465bfd4 into llvm:main May 22, 2024
4 checks passed
@aaupov aaupov deleted the simplify-ctc-bat branch May 22, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants