diff --git a/llvm/test/Reduce/remove-args-2.ll b/llvm/test/Reduce/remove-args-2.ll new file mode 100644 --- /dev/null +++ b/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 +} diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp --- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp +++ b/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