Skip to content

Commit 5fb59e7

Browse files
authored
[BOLT] Print program stats in perf2bolt/aggregate-only mode (#89763)
1 parent 2db7820 commit 5fb59e7

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

bolt/include/bolt/Passes/BinaryPasses.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,7 @@ class PrintProfileStats : public BinaryFunctionPass {
400400
/// dyno stats categories.
401401
class PrintProgramStats : public BinaryFunctionPass {
402402
public:
403-
explicit PrintProgramStats(const cl::opt<bool> &PrintPass)
404-
: BinaryFunctionPass(PrintPass) {}
403+
explicit PrintProgramStats() : BinaryFunctionPass(false) {}
405404

406405
const char *getName() const override { return "print-stats"; }
407406
bool shouldPrint(const BinaryFunction &) const override { return false; }

bolt/lib/Profile/DataAggregator.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "bolt/Profile/DataAggregator.h"
1515
#include "bolt/Core/BinaryContext.h"
1616
#include "bolt/Core/BinaryFunction.h"
17+
#include "bolt/Passes/BinaryPasses.h"
1718
#include "bolt/Profile/BoltAddressTranslation.h"
1819
#include "bolt/Profile/Heatmap.h"
1920
#include "bolt/Profile/YAMLProfileWriter.h"
@@ -611,6 +612,7 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
611612
if (std::error_code EC = writeBATYAML(BC, opts::SaveProfile))
612613
report_error("cannot create output data file", EC);
613614
}
615+
BC.logBOLTErrorsAndQuitOnFatal(PrintProgramStats().runOnFunctions(BC));
614616
}
615617

616618
return Error::success();

bolt/lib/Rewrite/BinaryPassManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
356356
// order they're registered.
357357

358358
// Run this pass first to use stats for the original functions.
359-
Manager.registerPass(std::make_unique<PrintProgramStats>(NeverPrint));
359+
Manager.registerPass(std::make_unique<PrintProgramStats>());
360360

361361
if (opts::PrintProfileStats)
362362
Manager.registerPass(std::make_unique<PrintProfileStats>(NeverPrint));

bolt/lib/Rewrite/BoltDiff.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class RewriteInstanceDiff {
292292
}
293293
}
294294
}
295-
PrintProgramStats PPS(opts::NeverPrint);
295+
PrintProgramStats PPS;
296296
outs() << "* BOLT-DIFF: Starting print program stats pass for binary 1\n";
297297
RI1.BC->logBOLTErrorsAndQuitOnFatal(PPS.runOnFunctions(*RI1.BC));
298298
outs() << "* BOLT-DIFF: Starting print program stats pass for binary 2\n";

bolt/test/X86/pre-aggregated-perf.test

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ REQUIRES: system-linux
1111

1212
RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
1313
RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \
14-
RUN: --profile-use-dfs
14+
RUN: --profile-use-dfs | FileCheck %s
15+
16+
RUN: llvm-bolt %t.exe -data %t -o %t.null | FileCheck %s
17+
RUN: llvm-bolt %t.exe -data %t.new -o %t.null | FileCheck %s
18+
RUN: llvm-bolt %t.exe -p %p/Inputs/pre-aggregated.txt --pa -o %t.null | FileCheck %s
19+
20+
CHECK: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
21+
1522
RUN: cat %t | sort | FileCheck %s -check-prefix=PERF2BOLT
1623
RUN: cat %t.new | FileCheck %s -check-prefix=NEWFORMAT
1724

0 commit comments

Comments
 (0)