[llvm] 78fe6a3 - [NFC] Extract the code to write instr profile into function writeInstrProfile
Wei Mi via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 16:30:46 PDT 2020
Author: Wei Mi
Date: 2020-07-09T16:30:28-07:00
New Revision: 78fe6a3ee244cf1b590cd2a169c81ec00de08cb2
URL: https://github.com/llvm/llvm-project/commit/78fe6a3ee244cf1b590cd2a169c81ec00de08cb2
DIFF: https://github.com/llvm/llvm-project/commit/78fe6a3ee244cf1b590cd2a169c81ec00de08cb2.diff
LOG: [NFC] Extract the code to write instr profile into function writeInstrProfile
So that the function writeInstrProfile can be used in other places.
Differential Revision: https://reviews.llvm.org/D83521
Added:
Modified:
llvm/tools/llvm-profdata/llvm-profdata.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 1eb4bc66d60c..843f072a61c3 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -291,6 +291,22 @@ static void mergeWriterContexts(WriterContext *Dst, WriterContext *Src) {
});
}
+static void writeInstrProfile(StringRef OutputFilename,
+ ProfileFormat OutputFormat,
+ InstrProfWriter &Writer) {
+ std::error_code EC;
+ raw_fd_ostream Output(OutputFilename.data(), EC, sys::fs::OF_None);
+ if (EC)
+ exitWithErrorCode(EC, OutputFilename);
+
+ if (OutputFormat == PF_Text) {
+ if (Error E = Writer.writeText(Output))
+ exitWithError(std::move(E));
+ } else {
+ Writer.write(Output);
+ }
+}
+
static void mergeInstrProfile(const WeightedFileVector &Inputs,
SymbolRemapper *Remapper,
StringRef OutputFilename,
@@ -366,18 +382,7 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs,
(NumErrors > 0 && FailMode == failIfAnyAreInvalid))
exitWithError("No profiles could be merged.");
- std::error_code EC;
- raw_fd_ostream Output(OutputFilename.data(), EC, sys::fs::OF_None);
- if (EC)
- exitWithErrorCode(EC, OutputFilename);
-
- InstrProfWriter &Writer = Contexts[0]->Writer;
- if (OutputFormat == PF_Text) {
- if (Error E = Writer.writeText(Output))
- exitWithError(std::move(E));
- } else {
- Writer.write(Output);
- }
+ writeInstrProfile(OutputFilename, OutputFormat, Contexts[0]->Writer);
}
/// Make a copy of the given function samples with all symbol names remapped
More information about the llvm-commits
mailing list