llvm-reduce: Drop guessing output format based on file extension
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 29 Oct 2022 01:24:21 +0000 (18:24 -0700)
committerMatt Arsenault <arsenm2@gmail.com>
Tue, 1 Nov 2022 03:35:08 +0000 (20:35 -0700)
llvm/test/tools/llvm-reduce/file-output-type.test
llvm/test/tools/llvm-reduce/temporary-files-as-bitcode-split.ll
llvm/test/tools/llvm-reduce/temporary-files-as-bitcode.ll
llvm/tools/llvm-reduce/llvm-reduce.cpp

index e81a9dd..5535866 100644 (file)
 # RUN: llvm-dis -disable-output %t.0.bc
 
 
-# A .bc input file with a requested .ll output should produce text
+# A .bc input file with a requested .ll output
 # RUN: rm -f reduced.ll reduced.bc
 # RUN: llvm-reduce --delta-passes=instructions -o %t.0.ll --test FileCheck --test-arg %s --test-arg --input-file test-output-format.bc
-# RUN: llvm-as -disable-output %t.0.ll
+# RUN: llvm-dis -disable-output %t.0.ll
 
 
-# A file name ending in .bc should default to bitcode output
+# A file name ending in .bc
 # RUN: llvm-reduce -o %t.1.bc --delta-passes=instructions --test FileCheck --test-arg %s --test-arg --input-file %p/Inputs/test-output-format.ll
-# RUN: llvm-dis -disable-output %t.1.bc
+# RUN: llvm-as -disable-output %t.1.bc
 
 
 # Make sure an explicit -output-bitcode produces bitcode output regardless of suffix
index a7bbe65..40a6656 100644 (file)
@@ -1,7 +1,7 @@
 ; RUN: opt --thinlto-bc --thinlto-split-lto-unit %s -o %t0
 ; RUN: llvm-reduce -write-tmp-files-as-bitcode --delta-passes=function-bodies,basic-blocks %t0 -o %t1 \
 ; RUN:     --test %python --test-arg %p/Inputs/llvm-dis-and-filecheck.py --test-arg llvm-dis --test-arg FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s
-; RUN: cat %t1* | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s
+; RUN: llvm-dis < %t1* | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s
 
 @g = internal global i8 42, !type !0
 
index c1790bf..2ffe18d 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llvm-reduce -write-tmp-files-as-bitcode --delta-passes=function-bodies,basic-blocks %s -o %t \
 ; RUN:     --test %python --test-arg %p/Inputs/llvm-dis-and-filecheck.py --test-arg llvm-dis --test-arg FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s
-; RUN: cat %t | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s
+; RUN: FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s < %t
 
 ; CHECK-INTERESTINGNESS: @callee(
 ; CHECK-FINAL: declare void @callee()
index 627d30b..4439a3c 100644 (file)
@@ -95,20 +95,17 @@ bool isReduced(ReducerWorkItem &M, TestRunner &Test);
 
 static std::pair<StringRef, bool> determineOutputType(bool IsMIR,
                                                       bool InputIsBitcode) {
-  bool OutputBitcode = ForceOutputBitcode;
+  bool OutputBitcode = ForceOutputBitcode || InputIsBitcode;
 
   if (ReplaceInput) { // In-place
     OutputFilename = InputFilename.c_str();
-    OutputBitcode |= StringRef(OutputFilename).endswith(".bc");
-  } else if (OutputFilename.empty() || OutputFilename == "-") {
+  } else if (OutputFilename.empty()) {
     // Default to producing bitcode if the input was bitcode, if not explicitly
     // requested.
 
-    OutputBitcode |= InputIsBitcode;
     OutputFilename =
         IsMIR ? "reduced.mir" : (OutputBitcode ? "reduced.bc" : "reduced.ll");
-  } else
-    OutputBitcode |= StringRef(OutputFilename).endswith(".bc");
+  }
 
   return {OutputFilename, OutputBitcode};
 }