[llvm] [BOLT] Print program stats in perf2bolt/aggregate-only mode (PR #89763)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 06:21:30 PDT 2024


https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/89763

Produce the message with profiled functions in perf2bolt.

Test Plan: updated pre-aggregated-perf.test


>From 9fd16a5a95705cd6bccc6e2537655862ae27e957 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Mon, 22 Apr 2024 19:22:55 -0700
Subject: [PATCH] [BOLT] Print program stats in perf2bolt/aggregate-only mode

Produce the message with profiled functions in perf2bolt.

Test Plan: updated pre-aggregated-perf.test
---
 bolt/lib/Profile/DataAggregator.cpp    | 4 ++++
 bolt/test/X86/pre-aggregated-perf.test | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index 0b2a4e86561f3a..2dbfa5d6918505 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -14,6 +14,7 @@
 #include "bolt/Profile/DataAggregator.h"
 #include "bolt/Core/BinaryContext.h"
 #include "bolt/Core/BinaryFunction.h"
+#include "bolt/Passes/BinaryPasses.h"
 #include "bolt/Profile/BoltAddressTranslation.h"
 #include "bolt/Profile/Heatmap.h"
 #include "bolt/Profile/YAMLProfileWriter.h"
@@ -85,6 +86,7 @@ MaxSamples("max-samples",
   cl::Hidden,
   cl::cat(AggregatorCategory));
 
+extern cl::opt<bool> NeverPrint;
 extern cl::opt<opts::ProfileFormatKind> ProfileFormat;
 extern cl::opt<std::string> SaveProfile;
 
@@ -611,6 +613,8 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
         if (std::error_code EC = writeBATYAML(BC, opts::SaveProfile))
           report_error("cannot create output data file", EC);
     }
+    PrintProgramStats PPS(opts::NeverPrint);
+    BC.logBOLTErrorsAndQuitOnFatal(PPS.runOnFunctions(BC));
   }
 
   return Error::success();
diff --git a/bolt/test/X86/pre-aggregated-perf.test b/bolt/test/X86/pre-aggregated-perf.test
index e8c3f64239a27d..0bd44720f1b7a1 100644
--- a/bolt/test/X86/pre-aggregated-perf.test
+++ b/bolt/test/X86/pre-aggregated-perf.test
@@ -11,7 +11,14 @@ REQUIRES: system-linux
 
 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
 RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \
-RUN:   --profile-use-dfs
+RUN:   --profile-use-dfs | FileCheck %s
+
+RUN: llvm-bolt %t.exe -data %t -o %t.null | FileCheck %s
+RUN: llvm-bolt %t.exe -data %t.new -o %t.null | FileCheck %s
+RUN: llvm-bolt %t.exe -p %p/Inputs/pre-aggregated.txt --pa -o %t.null | FileCheck %s
+
+CHECK: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
+
 RUN: cat %t | sort | FileCheck %s -check-prefix=PERF2BOLT
 RUN: cat %t.new | FileCheck %s -check-prefix=NEWFORMAT
 



More information about the llvm-commits mailing list