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

This commit is contained in:
Amir Ayupov
2024-04-25 19:08:51 +02:00
committed by GitHub
parent 2db782047b
commit 5fb59e7447
5 changed files with 13 additions and 5 deletions

View File

@@ -400,8 +400,7 @@ public:
/// dyno stats categories.
class PrintProgramStats : public BinaryFunctionPass {
public:
explicit PrintProgramStats(const cl::opt<bool> &PrintPass)
: BinaryFunctionPass(PrintPass) {}
explicit PrintProgramStats() : BinaryFunctionPass(false) {}
const char *getName() const override { return "print-stats"; }
bool shouldPrint(const BinaryFunction &) const override { return false; }

View File

@@ -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"
@@ -611,6 +612,7 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
if (std::error_code EC = writeBATYAML(BC, opts::SaveProfile))
report_error("cannot create output data file", EC);
}
BC.logBOLTErrorsAndQuitOnFatal(PrintProgramStats().runOnFunctions(BC));
}
return Error::success();

View File

@@ -356,7 +356,7 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
// order they're registered.
// Run this pass first to use stats for the original functions.
Manager.registerPass(std::make_unique<PrintProgramStats>(NeverPrint));
Manager.registerPass(std::make_unique<PrintProgramStats>());
if (opts::PrintProfileStats)
Manager.registerPass(std::make_unique<PrintProfileStats>(NeverPrint));

View File

@@ -292,7 +292,7 @@ class RewriteInstanceDiff {
}
}
}
PrintProgramStats PPS(opts::NeverPrint);
PrintProgramStats PPS;
outs() << "* BOLT-DIFF: Starting print program stats pass for binary 1\n";
RI1.BC->logBOLTErrorsAndQuitOnFatal(PPS.runOnFunctions(*RI1.BC));
outs() << "* BOLT-DIFF: Starting print program stats pass for binary 2\n";

View File

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