[PATCH] D144211: [BOLT] computing raw branch count for yaml profiles

Sergey Pupyrev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 11:48:27 PST 2023


spupyrev created this revision.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
spupyrev requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144211

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/lib/Core/BinaryFunction.cpp
  bolt/lib/Profile/YAMLProfileReader.cpp


Index: bolt/lib/Profile/YAMLProfileReader.cpp
===================================================================
--- bolt/lib/Profile/YAMLProfileReader.cpp
+++ bolt/lib/Profile/YAMLProfileReader.cpp
@@ -83,6 +83,14 @@
 
   BF.setExecutionCount(YamlBF.ExecCount);
 
+  uint64_t FuncRawBranchCount = 0;
+  for (const yaml::bolt::BinaryBasicBlockProfile &YamlBB : YamlBF.Blocks) {
+    for (const yaml::bolt::SuccessorInfo &YamlSI : YamlBB.Successors) {
+      FuncRawBranchCount += YamlSI.Count;
+    }
+  }
+  BF.setRawBranchCount(FuncRawBranchCount);
+
   if (!opts::IgnoreHash && YamlBF.Hash != BF.computeHash(/*UseDFS=*/true)) {
     if (opts::Verbosity >= 1)
       errs() << "BOLT-WARNING: function hash mismatch\n";
Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -471,6 +471,7 @@
   if (ExecutionCount != COUNT_NO_PROFILE) {
     OS << "\n  Exec Count  : " << ExecutionCount;
     OS << "\n  Profile Acc : " << format("%.1f%%", ProfileMatchRatio * 100.0f);
+    OS << "\n  RawBranchCount : " << RawBranchCount;
   }
 
   if (opts::PrintDynoStats && !getLayout().block_empty()) {
Index: bolt/include/bolt/Core/BinaryFunction.h
===================================================================
--- bolt/include/bolt/Core/BinaryFunction.h
+++ bolt/include/bolt/Core/BinaryFunction.h
@@ -1868,6 +1868,10 @@
   /// executions corresponding to this function.
   uint64_t getRawBranchCount() const { return RawBranchCount; }
 
+  /// Set the profile data about the number of branch executions corresponding
+  /// to this function.
+  void setRawBranchCount(uint64_t Count) { RawBranchCount = Count; }
+
   /// Return the execution count for functions with known profile.
   /// Return 0 if the function has no profile.
   uint64_t getKnownExecutionCount() const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144211.498113.patch
Type: text/x-patch
Size: 1904 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230216/2e9c9fb4/attachment.bin>


More information about the llvm-commits mailing list