mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 03:50:17 +08:00
[BOLT] Print program stats in perf2bolt/aggregate-only mode (#89763)
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user