Skip to content
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

[BOLT][NFC] Rename DataAggregator::BranchInfo to TakenBranchInfo #92017

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented May 13, 2024

Align the name to its counterpart FTInfo which avoids name aliasing
with llvm::bolt::BranchInfo and allows to drop namespace specifier.

Test Plan: NFC

Created using spr 1.3.4
@llvmbot
Copy link

llvmbot commented May 13, 2024

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

Changes

Avoid name aliasing with llvm::bolt::BranchInfo, drop namespace
specifier.

Test Plan: NFC


Full diff: https://github.com/llvm/llvm-project/pull/92017.diff

2 Files Affected:

  • (modified) bolt/include/bolt/Profile/DataAggregator.h (+2-2)
  • (modified) bolt/lib/Profile/DataAggregator.cpp (+6-6)
diff --git a/bolt/include/bolt/Profile/DataAggregator.h b/bolt/include/bolt/Profile/DataAggregator.h
index f2fa59bcaa1a3..48f01511f4827 100644
--- a/bolt/include/bolt/Profile/DataAggregator.h
+++ b/bolt/include/bolt/Profile/DataAggregator.h
@@ -122,14 +122,14 @@ class DataAggregator : public DataReader {
     uint64_t ExternCount{0};
   };
 
-  struct BranchInfo {
+  struct TakenInfo {
     uint64_t TakenCount{0};
     uint64_t MispredCount{0};
   };
 
   /// Intermediate storage for profile data. We save the results of parsing
   /// and use them later for processing and assigning profile.
-  std::unordered_map<Trace, BranchInfo, TraceHash> BranchLBRs;
+  std::unordered_map<Trace, TakenInfo, TraceHash> BranchLBRs;
   std::unordered_map<Trace, FTInfo, TraceHash> FallthroughLBRs;
   std::vector<AggregatedLBREntry> AggregatedLBRs;
   std::unordered_map<uint64_t, uint64_t> BasicSamples;
diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index 167899ccba125..0e11963c676f0 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -1464,7 +1464,7 @@ uint64_t DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
     uint64_t To = getBinaryFunctionContainingAddress(LBR.To) ? LBR.To : 0;
     if (!From && !To)
       continue;
-    BranchInfo &Info = BranchLBRs[Trace(From, To)];
+    TakenInfo &Info = BranchLBRs[Trace(From, To)];
     ++Info.TakenCount;
     Info.MispredCount += LBR.Mispred;
   }
@@ -1609,7 +1609,7 @@ void DataAggregator::processBranchEvents() {
 
   for (const auto &AggrLBR : BranchLBRs) {
     const Trace &Loc = AggrLBR.first;
-    const BranchInfo &Info = AggrLBR.second;
+    const TakenInfo &Info = AggrLBR.second;
     doBranch(Loc.From, Loc.To, Info.TakenCount, Info.MispredCount);
   }
 }
@@ -2253,13 +2253,13 @@ DataAggregator::writeAggregatedFile(StringRef OutputFilename) const {
   } else {
     for (const auto &KV : NamesToBranches) {
       const FuncBranchData &FBD = KV.second;
-      for (const llvm::bolt::BranchInfo &BI : FBD.Data) {
+      for (const BranchInfo &BI : FBD.Data) {
         writeLocation(BI.From);
         writeLocation(BI.To);
         OutFile << BI.Mispreds << " " << BI.Branches << "\n";
         ++BranchValues;
       }
-      for (const llvm::bolt::BranchInfo &BI : FBD.EntryData) {
+      for (const BranchInfo &BI : FBD.EntryData) {
         // Do not output if source is a known symbol, since this was already
         // accounted for in the source function
         if (BI.From.IsSymbol)
@@ -2366,7 +2366,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
         return std::pair(BlockIt->first, BlockIt->second.getBBIndex());
       };
 
-      for (const llvm::bolt::BranchInfo &BI : Branches.Data) {
+      for (const BranchInfo &BI : Branches.Data) {
         using namespace yaml::bolt;
         const auto &[BlockOffset, BlockIndex] = getBlock(BI.From.Offset);
         BinaryBasicBlockProfile &YamlBB = YamlBF.Blocks[BlockIndex];
@@ -2388,7 +2388,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
         }
       }
       // Set entry counts, similar to DataReader::readProfile.
-      for (const llvm::bolt::BranchInfo &BI : Branches.EntryData) {
+      for (const BranchInfo &BI : Branches.EntryData) {
         if (!BlockMap.isInputBlock(BI.To.Offset)) {
           if (opts::Verbosity >= 1)
             errs() << "BOLT-WARNING: Unexpected EntryData in " << FuncName

@dcci
Copy link
Member

dcci commented May 13, 2024

I would suggest BranchTakenInfo rather than TakenInfo but up to you/@maksfb

Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@aaupov
Copy link
Contributor Author

aaupov commented May 14, 2024

I would suggest BranchTakenInfo rather than TakenInfo but up to you/@maksfb

TakenBranchInfo is a better-sounding order at least to me. @maksfb - you choose :)

wangleiat and others added 3 commits May 16, 2024 22:57
Created using spr 1.3.5

[skip ci]
Created using spr 1.3.5
Created using spr 1.3.5
@aaupov aaupov changed the title [BOLT][NFC] Rename DataAggregator::BranchInfo to TakenInfo [BOLT][NFC] Rename DataAggregator::BranchInfo to TakenBranchInfo May 17, 2024
@aaupov aaupov changed the base branch from users/aaupov/spr/main.boltnfc-rename-dataaggregatorbranchinfo-to-takeninfo to main May 17, 2024 03:01
@aaupov aaupov merged commit 9f15aa0 into main May 17, 2024
2 of 3 checks passed
@aaupov aaupov deleted the users/aaupov/spr/boltnfc-rename-dataaggregatorbranchinfo-to-takeninfo branch May 17, 2024 03:02
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