[llvm] ce05211 - [Reduce] Argument reduction: don't try to drop terminator instructions
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 20 14:06:23 PDT 2020
Author: Roman Lebedev
Date: 2020-07-21T00:06:03+03:00
New Revision: ce052110ac9c03f14e16a0f46697da2eabc7ac4c
URL: https://github.com/llvm/llvm-project/commit/ce052110ac9c03f14e16a0f46697da2eabc7ac4c
DIFF: https://github.com/llvm/llvm-project/commit/ce052110ac9c03f14e16a0f46697da2eabc7ac4c.diff
LOG: [Reduce] Argument reduction: don't try to drop terminator instructions
Newly-added test previously crashed.
While it is up for debate whether or not instruction reduction
should be indiscriminate in instruction dropping (there you can
just ensure that the test case is still -verify'ies), here
if we drop terminator, CloneFunctionInto() will immediately crash.
So let's not do that :)
Added:
llvm/test/Reduce/remove-args-used-by-ret.ll
Modified:
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
Removed:
################################################################################
diff --git a/llvm/test/Reduce/remove-args-used-by-ret.ll b/llvm/test/Reduce/remove-args-used-by-ret.ll
new file mode 100644
index 000000000000..13b7fe58e5f0
--- /dev/null
+++ b/llvm/test/Reduce/remove-args-used-by-ret.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: cat %t | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL %s
+
+; We can't drop arguments if they are used by terminator instructions.
+
+define i32 @t(i32 %a0, i32 %a1, i32 %a2) {
+; CHECK-ALL-LABEL: @t
+; CHECK-FINAL-NOT: %a1
+;
+; CHECK-INTERESTINGNESS: ret i32
+; CHECK-FINAL: ret i32 undef
+
+ ret i32 %a1
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
index 88c3e326ff97..e0e1d1c22567 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -73,7 +73,8 @@ static void extractArgumentsFromModule(std::vector<Chunk> ChunksToKeep,
continue;
auto *I = cast<Instruction>(V);
I->replaceAllUsesWith(UndefValue::get(I->getType()));
- I->eraseFromParent();
+ if (!I->isTerminator())
+ I->eraseFromParent();
}
// No arguments to reduce
More information about the llvm-commits
mailing list