[PATCH] D108903: [llvm-reduce] Add reduce operands pass

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 15 17:03:23 PDT 2021


aeubanks added a comment.

almost there



================
Comment at: llvm/test/tools/llvm-reduce/no-replace-intrinsic-callee-with-undef.ll:6
 
-; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2> %t.log
+; RUN: llvm-reduce --delta-passes=functions,instructions,operand-bundles --test FileCheck --test-arg --check-prefixes=ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2> %t.log
 ; RUN: FileCheck -implicit-check-not=uninteresting --check-prefixes=ALL,CHECK-FINAL %s < %t
----------------
this doesn't contain any operand bundles, so the pass shouldn't be necessary


================
Comment at: llvm/test/tools/llvm-reduce/remove-invoked-functions.ll:1
-; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: llvm-reduce --delta-passes=functions,function-bodies,arguments,attributes --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
----------------
I think the following is cleaner:
```
diff --git a/llvm/test/tools/llvm-reduce/remove-invoked-functions.ll b/llvm/test/tools/llvm-reduce/remove-invoked-functions.ll
index e1224b99e176..0d3f8f87fd4a 100644
--- a/llvm/test/tools/llvm-reduce/remove-invoked-functions.ll
+++ b/llvm/test/tools/llvm-reduce/remove-invoked-functions.ll
@@ -1,4 +1,4 @@
-; RUN: llvm-reduce --delta-passes=functions,function-bodies,arguments,attributes --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; 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
 
 ; CHECK-INTERESTINGNESS: define i32 @maybe_throwing_callee(
@@ -22,8 +22,8 @@ declare void @thrown()
 define void @caller(i32 %arg) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
 ; CHECK-ALL: bb:
 bb:
-; CHECK-INTERESTINGNESS: %i0 = invoke i32
-; CHECK-FINAL: %i0 = invoke i32 bitcast (i32 ()* @maybe_throwing_callee to i32 (i32)*)(i32 %arg)
+; CHECK-INTERESTINGNESS: %i0 = invoke i32 {{.*}}@maybe_throwing_callee
+; CHECK-FINAL: %i0 = invoke i32 bitcast (i32 ()* @maybe_throwing_callee to i32 (i32)*)
 ; CHECK-ALL: to label %bb3 unwind label %bb1
   %i0 = invoke i32 @maybe_throwing_callee(i32 %arg)
           to label %bb3 unwind label %bb1
```


================
Comment at: llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp:16
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/InstIterator.h"
----------------
do we need this?


================
Comment at: llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp:18
+#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/ValueSymbolTable.h"
+
----------------
do we need this?


================
Comment at: llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp:22
+
+/// Returns if the given operand is undefined.
+static bool operandIsUndefValue(Use &Op) {
----------------
undef


================
Comment at: llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp:36
+  // check what types that are not reducible
+  return !Ty->isLabelTy() && !Ty->isTokenTy() && !operandIsUndefValue(Op);
+}
----------------
we actually can replace token values with an undef

e.g.
```
declare void @llvm.foo(token)

define void @f() {
  call void @llvm.foo(token undef)
  ret void
}
```
verifies


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108903



More information about the llvm-commits mailing list