[llvm] 4e21bc0 - llvm-reduce: Drop guessing output format based on file extension
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 20:35:16 PDT 2022
Author: Matt Arsenault
Date: 2022-10-31T20:35:08-07:00
New Revision: 4e21bc0c40a79957e6a979c6c9d364906341cdd4
URL: https://github.com/llvm/llvm-project/commit/4e21bc0c40a79957e6a979c6c9d364906341cdd4
DIFF: https://github.com/llvm/llvm-project/commit/4e21bc0c40a79957e6a979c6c9d364906341cdd4.diff
LOG: llvm-reduce: Drop guessing output format based on file extension
Added:
Modified:
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
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-reduce/file-output-type.test b/llvm/test/tools/llvm-reduce/file-output-type.test
index e81a9ddbb893..5535866e7251 100644
--- a/llvm/test/tools/llvm-reduce/file-output-type.test
+++ b/llvm/test/tools/llvm-reduce/file-output-type.test
@@ -18,15 +18,15 @@
# 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
diff --git a/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode-split.ll b/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode-split.ll
index a7bbe6586466..40a6656200f5 100644
--- a/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode-split.ll
+++ b/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode-split.ll
@@ -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
diff --git a/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode.ll b/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode.ll
index c1790bf4e080..2ffe18ddf2de 100644
--- a/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode.ll
+++ b/llvm/test/tools/llvm-reduce/temporary-files-as-bitcode.ll
@@ -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()
diff --git a/llvm/tools/llvm-reduce/llvm-reduce.cpp b/llvm/tools/llvm-reduce/llvm-reduce.cpp
index 627d30b81ed9..4439a3cbe6a8 100644
--- a/llvm/tools/llvm-reduce/llvm-reduce.cpp
+++ b/llvm/tools/llvm-reduce/llvm-reduce.cpp
@@ -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};
}
More information about the llvm-commits
mailing list