@@ -291,6 +291,22 @@ static void mergeWriterContexts(WriterContext *Dst, WriterContext *Src) {
291
291
});
292
292
}
293
293
294
+ static void writeInstrProfile (StringRef OutputFilename,
295
+ ProfileFormat OutputFormat,
296
+ InstrProfWriter &Writer) {
297
+ std::error_code EC;
298
+ raw_fd_ostream Output (OutputFilename.data (), EC, sys::fs::OF_None);
299
+ if (EC)
300
+ exitWithErrorCode (EC, OutputFilename);
301
+
302
+ if (OutputFormat == PF_Text) {
303
+ if (Error E = Writer.writeText (Output))
304
+ exitWithError (std::move (E));
305
+ } else {
306
+ Writer.write (Output);
307
+ }
308
+ }
309
+
294
310
static void mergeInstrProfile (const WeightedFileVector &Inputs,
295
311
SymbolRemapper *Remapper,
296
312
StringRef OutputFilename,
@@ -366,18 +382,7 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs,
366
382
(NumErrors > 0 && FailMode == failIfAnyAreInvalid))
367
383
exitWithError (" No profiles could be merged." );
368
384
369
- std::error_code EC;
370
- raw_fd_ostream Output (OutputFilename.data (), EC, sys::fs::OF_None);
371
- if (EC)
372
- exitWithErrorCode (EC, OutputFilename);
373
-
374
- InstrProfWriter &Writer = Contexts[0 ]->Writer ;
375
- if (OutputFormat == PF_Text) {
376
- if (Error E = Writer.writeText (Output))
377
- exitWithError (std::move (E));
378
- } else {
379
- Writer.write (Output);
380
- }
385
+ writeInstrProfile (OutputFilename, OutputFormat, Contexts[0 ]->Writer );
381
386
}
382
387
383
388
// / Make a copy of the given function samples with all symbol names remapped
0 commit comments