[tools] Mark output of tools as text if it is really text

This is a continuation of https://reviews.llvm.org/D67696. The following tools also need to set the OF_Text flag correctly.

  -   llvm-profdata
  -   llvm-link

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D94313
This commit is contained in:
Abhina Sreeskantharajan 2021-01-11 15:13:40 -05:00
parent 5ed102c708
commit 96ca3dd89b
4 changed files with 7 additions and 4 deletions

View File

@ -27,5 +27,5 @@ Roundtrip test:
RUN: llvm-profdata merge -o %t.0.profdata %S/Inputs/CSIR_profile.proftext
RUN: llvm-profdata merge -text -o %t.0.proftext %t.0.profdata
RUN: diff %t.0.proftext %S/Inputs/CSIR_profile.proftext
RUN: diff -b %t.0.proftext %S/Inputs/CSIR_profile.proftext

View File

@ -1,2 +1,2 @@
; RUN: llvm-profdata merge -text %S/Inputs/instr-remap.proftext -r %S/Inputs/instr-remap.remap -o %t.output
; RUN: diff %S/Inputs/instr-remap.expected %t.output
; RUN: diff -b %S/Inputs/instr-remap.expected %t.output

View File

@ -456,7 +456,8 @@ int main(int argc, char **argv) {
errs() << "Here's the assembly:\n" << *Composite;
std::error_code EC;
ToolOutputFile Out(OutputFilename, EC, sys::fs::OF_None);
ToolOutputFile Out(OutputFilename, EC,
OutputAssembly ? sys::fs::OF_Text : sys::fs::OF_None);
if (EC) {
WithColor::error() << EC.message() << '\n';
return 1;

View File

@ -296,7 +296,9 @@ static void writeInstrProfile(StringRef OutputFilename,
ProfileFormat OutputFormat,
InstrProfWriter &Writer) {
std::error_code EC;
raw_fd_ostream Output(OutputFilename.data(), EC, sys::fs::OF_None);
raw_fd_ostream Output(OutputFilename.data(), EC,
OutputFormat == PF_Text ? sys::fs::OF_Text
: sys::fs::OF_None);
if (EC)
exitWithErrorCode(EC, OutputFilename);