[Bugpoint redesign] Output option can now print to STDOUT
Summary:
This also changes all the outs() statements to errs() so the output and
progress streams don't get mixed.
This has been added because D64176 had flaky tests, which I believe were because the reduced file was being catted into `FileCheck`, instead of being pass from STDOUT directly.
Reviewers: chandlerc, dblaikie, xbolva00
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66314
llvm-svn: 369060
diff --git a/llvm/tools/llvm-reduce/llvm-reduce.cpp b/llvm/tools/llvm-reduce/llvm-reduce.cpp
index 23c98b5..ec82ecb 100644
--- a/llvm/tools/llvm-reduce/llvm-reduce.cpp
+++ b/llvm/tools/llvm-reduce/llvm-reduce.cpp
@@ -89,17 +89,22 @@
StringRef ReducedFilename = sys::path::filename(Tester.getReducedFilepath());
if (ReducedFilename == sys::path::filename(InputFilename)) {
- outs() << "\nCouldnt reduce input :/\n";
+ errs() << "\nCouldnt reduce input :/\n";
} else {
- if (ReplaceInput) // In-place
- OutputFilename = InputFilename.c_str();
- else if (OutputFilename.empty())
- OutputFilename = "reduced.ll";
- else
- OutputFilename += ".ll";
+ // Print reduced file to STDOUT
+ if (OutputFilename == "-")
+ Tester.getProgram()->print(outs(), nullptr);
+ else {
+ if (ReplaceInput) // In-place
+ OutputFilename = InputFilename.c_str();
+ else if (OutputFilename.empty())
+ OutputFilename = "reduced.ll";
+ else
+ OutputFilename += ".ll";
- sys::fs::copy_file(Tester.getReducedFilepath(), OutputFilename);
- outs() << "\nDone reducing! Reduced IR to file: " << OutputFilename << "\n";
+ sys::fs::copy_file(Tester.getReducedFilepath(), OutputFilename);
+ errs() << "\nDone reducing! Reduced testcase: " << OutputFilename << "\n";
+ }
}
return 0;