[PATCH] D84099: [llvm-reduce] Fix off-by one in argument reduction pass
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 18 07:08:35 PDT 2020
arichardson created this revision.
arichardson added a reviewer: dblaikie.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The function extractArgumentsFromModule() was passing a one-based index to,
but replaceFunctionCalls() was expecting a zero-based argument index. This
resulted in assertion errors when reducing function call arguments with
different types.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84099
Files:
llvm/test/Reduce/remove-args-2.ll
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
Index: llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -84,7 +84,7 @@
int ArgI = 0;
for (auto &Arg : F->args())
if (ArgsToKeep.count(&Arg))
- ArgIndexesToKeep.insert(++ArgI);
+ ArgIndexesToKeep.insert(ArgI++);
auto *ClonedFunc = CloneFunction(F, VMap);
// In order to preserve function order, we move Clone after old Function
Index: llvm/test/Reduce/remove-args-2.ll
===================================================================
--- /dev/null
+++ llvm/test/Reduce/remove-args-2.ll
@@ -0,0 +1,20 @@
+; Test that llvm-reduce can remove uninteresting function arguments from function definitions as well as their calls.
+; This test checks that functions with different argument types are handled correctly
+;
+; RUN: llvm-reduce --test %python --test-arg %p/Inputs/remove-args.py %s -o %t
+; RUN: cat %t | FileCheck -implicit-check-not=uninteresting %s
+
+%struct.foo = type { %struct.foo*, i32, i32, i8* }
+
+define dso_local void @bar() {
+entry:
+ ; CHECK: call void @interesting(%struct.foo* null)
+ call void @interesting(%struct.foo* null, i8* null)
+ ret void
+}
+
+; CHECK: define internal void @interesting(%struct.foo* %interesting) {
+define internal void @interesting(%struct.foo* %interesting, i8* %uninteresting) {
+entry:
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84099.278999.patch
Type: text/x-patch
Size: 1483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200718/abd0e095/attachment.bin>
More information about the llvm-commits
mailing list