[PATCH] D84099: [llvm-reduce] Fix incorrect indices in argument reduction pass

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 19 10:07:23 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6187eeb683d8: [llvm-reduce] Fix incorrect indices in argument reduction pass (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84099/new/

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
@@ -81,10 +81,9 @@
       continue;
 
     std::set<int> ArgIndexesToKeep;
-    int ArgI = 0;
-    for (auto &Arg : F->args())
-      if (ArgsToKeep.count(&Arg))
-        ArgIndexesToKeep.insert(++ArgI);
+    for (auto &Arg : enumerate(F->args()))
+      if (ArgsToKeep.count(&Arg.value()))
+        ArgIndexesToKeep.insert(Arg.index());
 
     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(i32 0, i8* null, %struct.foo* null, i8* null, i64 0)
+  ret void
+}
+
+; CHECK: define internal void @interesting(%struct.foo* %interesting) {
+define internal void @interesting(i32 %uninteresting1, i8* %uninteresting2, %struct.foo* %interesting, i8* %uninteresting3, i64 %uninteresting4) {
+entry:
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84099.279098.patch
Type: text/x-patch
Size: 1720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200719/ae8725de/attachment.bin>


More information about the llvm-commits mailing list