Create Optimization Pass Wrapper for MLIR Reduce

Create a reduction pass that accepts an optimization pass as argument
and only replaces the golden module in the pipeline if the output of the
optimization pass is smaller than the input and still exhibits the
interesting behavior.

Add a -test-pass option to test individual passes in the MLIR Reduce
tool.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D84783
diff --git a/mlir/test/mlir-reduce/dce-test.mlir b/mlir/test/mlir-reduce/dce-test.mlir
new file mode 100644
index 0000000..e368343
--- /dev/null
+++ b/mlir/test/mlir-reduce/dce-test.mlir
@@ -0,0 +1,17 @@
+// UNSUPPORTED: -windows-
+// RUN: mlir-reduce %s -test %S/failure-test.sh -pass-test DCE | FileCheck %s
+// This input should be reduced by the pass pipeline so that only
+// the @simple1 function remains as the other fucntions should be
+// removed by the dead code elimination pass.
+// CHECK-LABEL: func @simple1(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
+
+// CHECK-NOT: func @dead_nested_function
+func @dead_private_function() attributes { sym_visibility = "private" }
+
+// CHECK-NOT: func @dead_nested_function
+func @dead_nested_function() attributes { sym_visibility = "nested" }
+
+func @simple1(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
+  "test.crashOp" () : () -> ()
+  return
+}