[PATCH] D126788: [BOLT] Add `-o` option to merge-fdata
Yi Kong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 1 10:29:20 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG716d428ab525: [BOLT] Add `-o` option to merge-fdata (authored by kongyi).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D126788?vs=433433&id=433452#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126788/new/
https://reviews.llvm.org/D126788
Files:
bolt/test/X86/merge-fdata-output.test
bolt/tools/merge-fdata/merge-fdata.cpp
Index: bolt/tools/merge-fdata/merge-fdata.cpp
===================================================================
--- bolt/tools/merge-fdata/merge-fdata.cpp
+++ bolt/tools/merge-fdata/merge-fdata.cpp
@@ -64,6 +64,12 @@
cl::Optional,
cl::cat(MergeFdataCategory));
+static cl::opt<std::string>
+OutputFilePath("o",
+ cl::value_desc("file"),
+ cl::desc("Write output to <file>"),
+ cl::cat(MergeFdataCategory));
+
} // namespace opts
namespace {
@@ -81,6 +87,18 @@
exit(1);
}
+static raw_fd_ostream &output() {
+ if (opts::OutputFilePath.empty() || opts::OutputFilePath == "-")
+ return outs();
+ else {
+ std::error_code EC;
+ static raw_fd_ostream Output(opts::OutputFilePath, EC);
+ if (EC)
+ report_error(opts::OutputFilePath, EC);
+ return Output;
+ }
+}
+
void mergeProfileHeaders(BinaryProfileHeader &MergedHeader,
const BinaryProfileHeader &Header) {
if (MergedHeader.FileName.empty())
@@ -283,9 +301,9 @@
}
if (BoltedCollection)
- outs() << "boltedcollection\n";
+ output() << "boltedcollection\n";
for (const auto &Entry : Entries)
- outs() << Entry.getKey() << " " << Entry.getValue() << "\n";
+ output() << Entry.getKey() << " " << Entry.getValue() << "\n";
errs() << "Profile from " << Filenames.size() << " files merged.\n";
}
@@ -375,7 +393,7 @@
}
if (!opts::SuppressMergedDataOutput) {
- yaml::Output YamlOut(outs());
+ yaml::Output YamlOut(output());
BinaryProfile MergedProfile;
MergedProfile.Header = MergedHeader;
Index: bolt/test/X86/merge-fdata-output.test
===================================================================
--- /dev/null
+++ bolt/test/X86/merge-fdata-output.test
@@ -0,0 +1,16 @@
+# Check merge-fdata tool correctly handles `-o` option.
+RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
+RUN: %S/Inputs/bat_profile_2.fdata \
+RUN: | FileCheck %s
+
+RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
+RUN: %S/Inputs/bat_profile_2.fdata \
+RUN: -o - \
+RUN: | FileCheck %s
+
+RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
+RUN: %S/Inputs/bat_profile_2.fdata \
+RUN: -o %t
+RUN: FileCheck %s < %t
+
+CHECK: 1 main 451 1 SolveCubic 0 0 302
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126788.433452.patch
Type: text/x-patch
Size: 2296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220601/5d55de64/attachment.bin>
More information about the llvm-commits
mailing list