[PATCH] D133995: [BOLT] Control aggregation mode output profile file format
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 15 17:16:10 PDT 2022
Amir created this revision.
Amir added a reviewer: bolt.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
In perf2bolt and `-aggregate-only` BOLT mode, the output profile file is written
in fdata format by default. Provide a knob `-profile-output=[fdata,yaml]` to
control the format.
Note that `-w` option still dumps in YAML format.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133995
Files:
bolt/include/bolt/Profile/DataAggregator.h
bolt/lib/Profile/DataAggregator.cpp
bolt/lib/Rewrite/RewriteInstance.cpp
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -208,6 +208,15 @@
clEnumValN(PPP_All, "all", "enable all debugging printout")),
cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
+cl::opt<ProfileOutputKind> ProfileOutput(
+ "profile-output",
+ cl::desc(
+ "format to dump profile output in aggregation mode, default is fdata"),
+ cl::init(PO_Fdata),
+ cl::values(clEnumValN(PO_Fdata, "fdata", "offset-based plaintext format"),
+ clEnumvalN(PO_YAML, "yaml", "dense YAML reprensentation")),
+ cl::ZeroOrMore, cl::Hidden, cl::cat(BoltCategory));
+
static cl::opt<cl::boolOrDefault> RelocationMode(
"relocs", cl::desc("use relocations in the binary (default=autodetect)"),
cl::cat(BoltCategory));
@@ -2792,10 +2801,15 @@
if (Error E = ProfileReader->readProfile(*BC.get()))
report_error("cannot read profile", std::move(E));
- if (!opts::SaveProfile.empty()) {
+ if (!opts::SaveProfile.empty())
YAMLProfileWriter PW(opts::SaveProfile);
PW.writeProfile(*this);
}
+ if (opts::AggregateOnly &&
+ opts::ProfileOutput == ProfileOutputKind::PO_YAML) {
+ YAMLProfileWriter PW(opts::OutputFilename);
+ PW.writeProfile(*this);
+ }
// Release memory used by profile reader.
ProfileReader.reset();
Index: bolt/lib/Profile/DataAggregator.cpp
===================================================================
--- bolt/lib/Profile/DataAggregator.cpp
+++ bolt/lib/Profile/DataAggregator.cpp
@@ -78,6 +78,8 @@
cl::Hidden,
cl::cat(AggregatorCategory));
+cl::opt<ProfileOutputKind> ProfileOutput;
+
cl::opt<bool> ReadPreAggregated(
"pa", cl::desc("skip perf and read data from a pre-aggregated file format"),
cl::cat(AggregatorCategory));
@@ -610,7 +612,8 @@
convertBranchData(Function);
}
- if (opts::AggregateOnly) {
+ if (opts::AggregateOnly &&
+ opts::ProfileOutput == ProfileOutputKind::PO_Fdata) {
if (std::error_code EC = writeAggregatedFile(opts::OutputFilename))
report_error("cannot create output data file", EC);
}
Index: bolt/include/bolt/Profile/DataAggregator.h
===================================================================
--- bolt/include/bolt/Profile/DataAggregator.h
+++ bolt/include/bolt/Profile/DataAggregator.h
@@ -27,6 +27,9 @@
class BinaryContext;
class BoltAddressTranslation;
+// The format to use with -o in aggregation mode (perf2bolt)
+enum ProfileOutputKind { PO_Fdata, PO_YAML };
+
/// DataAggregator inherits all parsing logic from DataReader as well as
/// its data structures used to represent aggregated profile data in memory.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133995.460560.patch
Type: text/x-patch
Size: 2776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220916/04414675/attachment.bin>
More information about the llvm-commits
mailing list