[Mlir-commits] [mlir] 87d6bf3 - [mlir][test] Generalize a bunch of FuncOp based passes to run on any operation/interfaces

River Riddle llvmlistbot at llvm.org
Tue Mar 8 12:28:59 PST 2022


Author: River Riddle
Date: 2022-03-08T12:25:32-08:00
New Revision: 87d6bf37288d47ddf702ac4da2cb61006feadbab

URL: https://github.com/llvm/llvm-project/commit/87d6bf37288d47ddf702ac4da2cb61006feadbab
DIFF: https://github.com/llvm/llvm-project/commit/87d6bf37288d47ddf702ac4da2cb61006feadbab.diff

LOG: [mlir][test] Generalize a bunch of FuncOp based passes to run on any operation/interfaces

A lot of test passes are currently anchored on FuncOp, but this
dependency
is generally just historical. A majority of these test passes can run on
any operation, or can operate on a specific interface
(FunctionOpInterface/SymbolOpInterface).
This allows for greatly reducing the API dependency on FuncOp, which
is slated to be moved out of the Builtin dialect.

Differential Revision: https://reviews.llvm.org/D121191

Added: 
    

Modified: 
    mlir/include/mlir/IR/FunctionInterfaces.h
    mlir/include/mlir/IR/FunctionInterfaces.td
    mlir/test/Analysis/test-dominance.mlir
    mlir/test/Analysis/test-liveness.mlir
    mlir/test/Analysis/test-match-reduction.mlir
    mlir/test/Analysis/test-topoligical-sort.mlir
    mlir/test/Dialect/Affine/loop-unswitch.mlir
    mlir/test/Dialect/Affine/memref-stride-calculation.mlir
    mlir/test/IR/diagnostic-handler-filter.mlir
    mlir/test/IR/test-matchers.mlir
    mlir/test/Transforms/parametric-mapping.mlir
    mlir/test/lib/Analysis/TestLiveness.cpp
    mlir/test/lib/Analysis/TestMatchReduction.cpp
    mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp
    mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
    mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp
    mlir/test/lib/Analysis/TestSlice.cpp
    mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp
    mlir/test/lib/Dialect/Affine/TestLoopMapping.cpp
    mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp
    mlir/test/lib/Dialect/GPU/TestGpuParallelLoopMapping.cpp
    mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp
    mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp
    mlir/test/lib/Dialect/Math/TestExpandTanh.cpp
    mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp
    mlir/test/lib/Dialect/MemRef/TestComposeSubView.cpp
    mlir/test/lib/Dialect/MemRef/TestMultiBuffer.cpp
    mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
    mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp
    mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp
    mlir/test/lib/IR/TestDiagnostics.cpp
    mlir/test/lib/IR/TestDominance.cpp
    mlir/test/lib/IR/TestFunc.cpp
    mlir/test/lib/IR/TestMatchers.cpp
    mlir/test/lib/IR/TestOpaqueLoc.cpp
    mlir/test/lib/IR/TestVisitors.cpp
    mlir/test/lib/Transforms/TestConstantFold.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/FunctionInterfaces.h b/mlir/include/mlir/IR/FunctionInterfaces.h
index 4b1e5260dfc54..f4ce672267d9b 100644
--- a/mlir/include/mlir/IR/FunctionInterfaces.h
+++ b/mlir/include/mlir/IR/FunctionInterfaces.h
@@ -16,6 +16,7 @@
 
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/OpDefinition.h"
+#include "mlir/IR/SymbolTable.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/SmallString.h"
 

diff  --git a/mlir/include/mlir/IR/FunctionInterfaces.td b/mlir/include/mlir/IR/FunctionInterfaces.td
index 22a3aee053ab0..7ba296baa246d 100644
--- a/mlir/include/mlir/IR/FunctionInterfaces.td
+++ b/mlir/include/mlir/IR/FunctionInterfaces.td
@@ -100,6 +100,14 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
     "::mlir::LogicalResult", "verifyType">,
   ];
 
+  let extraClassDeclaration = [{
+    //===------------------------------------------------------------------===//
+    // Name
+    //===------------------------------------------------------------------===//
+
+    /// Return the name of the function.
+    StringRef getName() { return SymbolTable::getSymbolName(*this); }
+  }];
   let extraSharedClassDeclaration = [{
     /// Block list iterator types.
     using BlockListType = Region::BlockListType;

diff  --git a/mlir/test/Analysis/test-dominance.mlir b/mlir/test/Analysis/test-dominance.mlir
index 88403c8a7754c..89d248a8a1494 100644
--- a/mlir/test/Analysis/test-dominance.mlir
+++ b/mlir/test/Analysis/test-dominance.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-print-dominance -split-input-file 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -pass-pipeline="builtin.func(test-print-dominance)" -split-input-file 2>&1 | FileCheck %s
 
 // CHECK-LABEL: Testing : func_condBranch
 func @func_condBranch(%cond : i1) {

diff  --git a/mlir/test/Analysis/test-liveness.mlir b/mlir/test/Analysis/test-liveness.mlir
index 570ef1fbdab16..6cd990bb29c29 100644
--- a/mlir/test/Analysis/test-liveness.mlir
+++ b/mlir/test/Analysis/test-liveness.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-print-liveness -split-input-file 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -pass-pipeline="builtin.func(test-print-liveness)" -split-input-file 2>&1 | FileCheck %s
 
 // CHECK-LABEL: Testing : func_empty
 func @func_empty() {

diff  --git a/mlir/test/Analysis/test-match-reduction.mlir b/mlir/test/Analysis/test-match-reduction.mlir
index a3b5e1a70af18..b5ef4110d9a7d 100644
--- a/mlir/test/Analysis/test-match-reduction.mlir
+++ b/mlir/test/Analysis/test-match-reduction.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-match-reduction -verify-diagnostics -split-input-file
+// RUN: mlir-opt %s -pass-pipeline="builtin.func(test-match-reduction)" -verify-diagnostics -split-input-file
 
 // Verify that the generic reduction detection utility works on 
diff erent
 // dialects.

diff  --git a/mlir/test/Analysis/test-topoligical-sort.mlir b/mlir/test/Analysis/test-topoligical-sort.mlir
index a93468580fa68..5e49b79986dd3 100644
--- a/mlir/test/Analysis/test-topoligical-sort.mlir
+++ b/mlir/test/Analysis/test-topoligical-sort.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-print-topological-sort 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -pass-pipeline="builtin.func(test-print-topological-sort)" 2>&1 | FileCheck %s
 
 // CHECK-LABEL: Testing : region
 //       CHECK: arith.addi {{.*}} : index

diff  --git a/mlir/test/Dialect/Affine/loop-unswitch.mlir b/mlir/test/Dialect/Affine/loop-unswitch.mlir
index ea023901d9d93..e7c3a7d585090 100644
--- a/mlir/test/Dialect/Affine/loop-unswitch.mlir
+++ b/mlir/test/Dialect/Affine/loop-unswitch.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -split-input-file -test-affine-loop-unswitch | FileCheck %s
+// RUN: mlir-opt %s -split-input-file -pass-pipeline="builtin.func(test-affine-loop-unswitch)" | FileCheck %s
 
 // CHECK-DAG: #[[$SET:.*]] = affine_set<(d0) : (d0 - 2 >= 0)>
 

diff  --git a/mlir/test/Dialect/Affine/memref-stride-calculation.mlir b/mlir/test/Dialect/Affine/memref-stride-calculation.mlir
index 9792cdc54ac06..06efd13f86ead 100644
--- a/mlir/test/Dialect/Affine/memref-stride-calculation.mlir
+++ b/mlir/test/Dialect/Affine/memref-stride-calculation.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-memref-stride-calculation -o /dev/null | FileCheck %s
+// RUN: mlir-opt %s -pass-pipeline="builtin.func(test-memref-stride-calculation)" -o /dev/null | FileCheck %s
 
 func @f(%0: index) {
 // CHECK-LABEL: Testing: f

diff  --git a/mlir/test/IR/diagnostic-handler-filter.mlir b/mlir/test/IR/diagnostic-handler-filter.mlir
index 40141d441a765..8630dbe492888 100644
--- a/mlir/test/IR/diagnostic-handler-filter.mlir
+++ b/mlir/test/IR/diagnostic-handler-filter.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-diagnostic-filter='filters=mysource1' -split-input-file -o - 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -pass-pipeline="builtin.func(test-diagnostic-filter{filters=mysource1})" -split-input-file -o - 2>&1 | FileCheck %s
 // This test verifies that diagnostic handler can emit the call stack successfully.
 
 // CHECK-LABEL: Test 'test1'

diff  --git a/mlir/test/IR/test-matchers.mlir b/mlir/test/IR/test-matchers.mlir
index 76f621331f210..948352494ee56 100644
--- a/mlir/test/IR/test-matchers.mlir
+++ b/mlir/test/IR/test-matchers.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -mlir-disable-threading=true -test-matchers -o /dev/null 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -mlir-disable-threading=true -pass-pipeline="builtin.func(test-matchers)" -o /dev/null 2>&1 | FileCheck %s
 
 func @test1(%a: f32, %b: f32, %c: f32) {
   %0 = arith.addf %a, %b: f32

diff  --git a/mlir/test/Transforms/parametric-mapping.mlir b/mlir/test/Transforms/parametric-mapping.mlir
index 6988d038f6d33..7d155e82fefa8 100644
--- a/mlir/test/Transforms/parametric-mapping.mlir
+++ b/mlir/test/Transforms/parametric-mapping.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt -allow-unregistered-dialect -test-mapping-to-processing-elements %s | FileCheck %s
+// RUN: mlir-opt -allow-unregistered-dialect -pass-pipeline="builtin.func(test-mapping-to-processing-elements)" %s | FileCheck %s
 
 // CHECK: #[[mul_map:.+]] = affine_map<()[s0, s1] -> (s0 * s1)>
 // CHECK: #[[add_map:.+]] = affine_map<()[s0, s1] -> (s0 + s1)>

diff  --git a/mlir/test/lib/Analysis/TestLiveness.cpp b/mlir/test/lib/Analysis/TestLiveness.cpp
index 0f758d557b18b..2af9e0c8dbfe1 100644
--- a/mlir/test/lib/Analysis/TestLiveness.cpp
+++ b/mlir/test/lib/Analysis/TestLiveness.cpp
@@ -1,5 +1,4 @@
-//===- TestLiveness.cpp - Test liveness construction and information
-//-------===//
+//===- TestLiveness.cpp - Test liveness construction and information ------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -20,7 +19,7 @@ using namespace mlir;
 namespace {
 
 struct TestLivenessPass
-    : public PassWrapper<TestLivenessPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestLivenessPass, InterfacePass<SymbolOpInterface>> {
   StringRef getArgument() const final { return "test-print-liveness"; }
   StringRef getDescription() const final {
     return "Print the contents of a constructed liveness information.";

diff  --git a/mlir/test/lib/Analysis/TestMatchReduction.cpp b/mlir/test/lib/Analysis/TestMatchReduction.cpp
index 843e37359082c..1d84d0d468f2b 100644
--- a/mlir/test/lib/Analysis/TestMatchReduction.cpp
+++ b/mlir/test/lib/Analysis/TestMatchReduction.cpp
@@ -11,6 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Analysis/SliceAnalysis.h"
+#include "mlir/IR/FunctionInterfaces.h"
 #include "mlir/Pass/Pass.h"
 
 using namespace mlir;
@@ -34,18 +35,19 @@ void printReductionResult(Operation *redRegionOp, unsigned numOutput,
 }
 
 struct TestMatchReductionPass
-    : public PassWrapper<TestMatchReductionPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestMatchReductionPass,
+                         InterfacePass<FunctionOpInterface>> {
   StringRef getArgument() const final { return "test-match-reduction"; }
   StringRef getDescription() const final {
     return "Test the match reduction utility.";
   }
 
   void runOnOperation() override {
-    FuncOp func = getOperation();
+    FunctionOpInterface func = getOperation();
     func->emitRemark("Testing function");
 
     func.walk<WalkOrder::PreOrder>([](Operation *op) {
-      if (isa<FuncOp>(op))
+      if (isa<FunctionOpInterface>(op))
         return;
 
       // Limit testing to ops with only one region.

diff  --git a/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp b/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp
index ea0e6ddb0ea42..6abdc1f63588e 100644
--- a/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp
+++ b/mlir/test/lib/Analysis/TestMemRefBoundCheck.cpp
@@ -28,10 +28,10 @@ namespace {
 
 /// Checks for out of bound memref access subscripts..
 struct TestMemRefBoundCheck
-    : public PassWrapper<TestMemRefBoundCheck, OperationPass<FuncOp>> {
+    : public PassWrapper<TestMemRefBoundCheck, OperationPass<>> {
   StringRef getArgument() const final { return "test-memref-bound-check"; }
   StringRef getDescription() const final {
-    return "Check memref access bounds in a Function";
+    return "Check memref access bounds";
   }
   void runOnOperation() override;
 };
@@ -39,7 +39,7 @@ struct TestMemRefBoundCheck
 } // namespace
 
 void TestMemRefBoundCheck::runOnOperation() {
-  getOperation().walk([](Operation *opInst) {
+  getOperation()->walk([](Operation *opInst) {
     TypeSwitch<Operation *>(opInst)
         .Case<AffineReadOpInterface, AffineWriteOpInterface>(
             [](auto op) { (void)boundCheckLoadOrStoreOp(op); });

diff  --git a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
index 066076970ace9..d8bd86d61c7af 100644
--- a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
+++ b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
@@ -27,7 +27,7 @@ namespace {
 // TODO: Add common surrounding loop depth-wise dependence checks.
 /// Checks dependences between all pairs of memref accesses in a Function.
 struct TestMemRefDependenceCheck
-    : public PassWrapper<TestMemRefDependenceCheck, OperationPass<FuncOp>> {
+    : public PassWrapper<TestMemRefDependenceCheck, OperationPass<>> {
   StringRef getArgument() const final { return "test-memref-dependence-check"; }
   StringRef getDescription() const final {
     return "Checks dependences between all pairs of memref accesses.";
@@ -100,12 +100,12 @@ static void checkDependences(ArrayRef<Operation *> loadsAndStores) {
   }
 }
 
-// Walks the Function 'f' adding load and store ops to 'loadsAndStores'.
-// Runs pair-wise dependence checks.
+/// Walks the operation adding load and store ops to 'loadsAndStores'. Runs
+/// pair-wise dependence checks.
 void TestMemRefDependenceCheck::runOnOperation() {
   // Collect the loads and stores within the function.
   loadsAndStores.clear();
-  getOperation().walk([&](Operation *op) {
+  getOperation()->walk([&](Operation *op) {
     if (isa<AffineLoadOp, AffineStoreOp>(op))
       loadsAndStores.push_back(op);
   });

diff  --git a/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp
index a0b9d039093c4..a22f833cff0db 100644
--- a/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp
+++ b/mlir/test/lib/Analysis/TestMemRefStrideCalculation.cpp
@@ -14,7 +14,8 @@ using namespace mlir;
 
 namespace {
 struct TestMemRefStrideCalculation
-    : public PassWrapper<TestMemRefStrideCalculation, OperationPass<FuncOp>> {
+    : public PassWrapper<TestMemRefStrideCalculation,
+                         InterfacePass<SymbolOpInterface>> {
   StringRef getArgument() const final {
     return "test-memref-stride-calculation";
   }

diff  --git a/mlir/test/lib/Analysis/TestSlice.cpp b/mlir/test/lib/Analysis/TestSlice.cpp
index 1a1cc4c1ea576..9b43e9f271d70 100644
--- a/mlir/test/lib/Analysis/TestSlice.cpp
+++ b/mlir/test/lib/Analysis/TestSlice.cpp
@@ -16,7 +16,8 @@ static const StringLiteral kOrderMarker = "__test_sort_original_idx__";
 namespace {
 
 struct TestTopologicalSortPass
-    : public PassWrapper<TestTopologicalSortPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestTopologicalSortPass,
+                         InterfacePass<SymbolOpInterface>> {
   StringRef getArgument() const final { return "test-print-topological-sort"; }
   StringRef getDescription() const final {
     return "Print operations in topological order";

diff  --git a/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp b/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp
index cd75a505e6409..b2854f39bdf50 100644
--- a/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestAffineLoopUnswitching.cpp
@@ -24,7 +24,7 @@ namespace {
 
 /// This pass applies the permutation on the first maximal perfect nest.
 struct TestAffineLoopUnswitching
-    : public PassWrapper<TestAffineLoopUnswitching, OperationPass<FuncOp>> {
+    : public PassWrapper<TestAffineLoopUnswitching, OperationPass<>> {
   StringRef getArgument() const final { return PASS_NAME; }
   StringRef getDescription() const final {
     return "Tests affine loop unswitching / if/else hoisting";
@@ -44,14 +44,14 @@ void TestAffineLoopUnswitching::runOnOperation() {
   // Each hoisting invalidates a lot of IR around. Just stop the walk after the
   // first if/else hoisting, and repeat until no more hoisting can be done, or
   // the maximum number of iterations have been run.
-  auto func = getOperation();
+  Operation *op = getOperation();
   unsigned i = 0;
   do {
     auto walkFn = [](AffineIfOp op) {
       return succeeded(hoistAffineIfOp(op)) ? WalkResult::interrupt()
                                             : WalkResult::advance();
     };
-    if (func.walk(walkFn).wasInterrupted())
+    if (op->walk(walkFn).wasInterrupted())
       break;
   } while (++i < kMaxIterations);
 }

diff  --git a/mlir/test/lib/Dialect/Affine/TestLoopMapping.cpp b/mlir/test/lib/Dialect/Affine/TestLoopMapping.cpp
index 78c2fb50d5745..cbdd1c7bf91ec 100644
--- a/mlir/test/lib/Dialect/Affine/TestLoopMapping.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestLoopMapping.cpp
@@ -23,7 +23,7 @@ using namespace mlir;
 
 namespace {
 class TestLoopMappingPass
-    : public PassWrapper<TestLoopMappingPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestLoopMappingPass, OperationPass<>> {
 public:
   StringRef getArgument() const final {
     return "test-mapping-to-processing-elements";
@@ -38,20 +38,18 @@ class TestLoopMappingPass
   }
 
   void runOnOperation() override {
-    FuncOp func = getOperation();
-
     // SSA values for the transformation are created out of thin air by
     // unregistered "new_processor_id_and_range" operations. This is enough to
     // emulate mapping conditions.
     SmallVector<Value, 8> processorIds, numProcessors;
-    func.walk([&processorIds, &numProcessors](Operation *op) {
+    getOperation()->walk([&processorIds, &numProcessors](Operation *op) {
       if (op->getName().getStringRef() != "new_processor_id_and_range")
         return;
       processorIds.push_back(op->getResult(0));
       numProcessors.push_back(op->getResult(1));
     });
 
-    func.walk([&processorIds, &numProcessors](scf::ForOp op) {
+    getOperation()->walk([&processorIds, &numProcessors](scf::ForOp op) {
       // Ignore nested loops.
       if (op->getParentRegion()->getParentOfType<scf::ForOp>())
         return;

diff  --git a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp
index ee8d371d33693..da3ca784f7e84 100644
--- a/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestLoopPermutation.cpp
@@ -19,13 +19,11 @@
 
 using namespace mlir;
 
-static llvm::cl::OptionCategory clOptionsCategory(PASS_NAME " options");
-
 namespace {
 
 /// This pass applies the permutation on the first maximal perfect nest.
 struct TestLoopPermutation
-    : public PassWrapper<TestLoopPermutation, OperationPass<FuncOp>> {
+    : public PassWrapper<TestLoopPermutation, OperationPass<>> {
   StringRef getArgument() const final { return PASS_NAME; }
   StringRef getDescription() const final {
     return "Tests affine loop permutation utility";
@@ -50,7 +48,7 @@ void TestLoopPermutation::runOnOperation() {
   SmallVector<unsigned, 4> permMap(permList.begin(), permList.end());
 
   SmallVector<AffineForOp, 2> forOps;
-  getOperation().walk([&](AffineForOp forOp) { forOps.push_back(forOp); });
+  getOperation()->walk([&](AffineForOp forOp) { forOps.push_back(forOp); });
 
   for (auto forOp : forOps) {
     SmallVector<AffineForOp, 6> nest;

diff  --git a/mlir/test/lib/Dialect/GPU/TestGpuParallelLoopMapping.cpp b/mlir/test/lib/Dialect/GPU/TestGpuParallelLoopMapping.cpp
index 61dc40db3098b..9cf9de6a38c83 100644
--- a/mlir/test/lib/Dialect/GPU/TestGpuParallelLoopMapping.cpp
+++ b/mlir/test/lib/Dialect/GPU/TestGpuParallelLoopMapping.cpp
@@ -21,7 +21,7 @@ namespace {
 /// a greedy mapping strategy.
 class TestGpuGreedyParallelLoopMappingPass
     : public PassWrapper<TestGpuGreedyParallelLoopMappingPass,
-                         OperationPass<FuncOp>> {
+                         OperationPass<>> {
   StringRef getArgument() const final {
     return "test-gpu-greedy-parallel-loop-mapping";
   }
@@ -29,8 +29,7 @@ class TestGpuGreedyParallelLoopMappingPass
     return "Greedily maps all parallel loops to gpu hardware ids.";
   }
   void runOnOperation() override {
-    Operation *op = getOperation();
-    for (Region &region : op->getRegions())
+    for (Region &region : getOperation()->getRegions())
       greedilyMapParallelSCFToGPU(region);
   }
 };

diff  --git a/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp b/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp
index b811e3c386c73..079d406344508 100644
--- a/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp
+++ b/mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp
@@ -20,7 +20,7 @@ namespace mlir {
 
 namespace {
 struct TestPadFusionPass
-    : public PassWrapper<TestPadFusionPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestPadFusionPass, OperationPass<>> {
 
   void getDependentDialects(DialectRegistry &registry) const override {
     registry
@@ -32,11 +32,10 @@ struct TestPadFusionPass
 
   void runOnOperation() override {
     MLIRContext *context = &getContext();
-    FuncOp funcOp = getOperation();
     RewritePatternSet patterns(context);
     linalg::populateFuseTensorPadWithProducerLinalgOpPatterns(patterns);
-    if (failed(applyPatternsAndFoldGreedily(funcOp.getBody(),
-                                            std::move(patterns))))
+    if (failed(
+            applyPatternsAndFoldGreedily(getOperation(), std::move(patterns))))
       return signalPassFailure();
   }
 };

diff  --git a/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp b/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp
index c91e9efc5eaf1..540fbf5570fe3 100644
--- a/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp
+++ b/mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp
@@ -20,8 +20,7 @@ using namespace mlir;
 
 namespace {
 struct TestMathAlgebraicSimplificationPass
-    : public PassWrapper<TestMathAlgebraicSimplificationPass,
-                         OperationPass<FuncOp>> {
+    : public PassWrapper<TestMathAlgebraicSimplificationPass, OperationPass<>> {
   void runOnOperation() override;
   void getDependentDialects(DialectRegistry &registry) const override {
     registry.insert<vector::VectorDialect, math::MathDialect>();

diff  --git a/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp b/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp
index f906863a3f92b..90dbb8649bbe8 100644
--- a/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp
+++ b/mlir/test/lib/Dialect/Math/TestExpandTanh.cpp
@@ -18,7 +18,7 @@ using namespace mlir;
 
 namespace {
 struct TestExpandTanhPass
-    : public PassWrapper<TestExpandTanhPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestExpandTanhPass, OperationPass<>> {
   void runOnOperation() override;
   StringRef getArgument() const final { return "test-expand-tanh"; }
   StringRef getDescription() const final { return "Test expanding tanh"; }

diff  --git a/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp b/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp
index 41f9db5cd795f..c26472c3d2984 100644
--- a/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp
+++ b/mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp
@@ -23,8 +23,7 @@ using namespace mlir;
 
 namespace {
 struct TestMathPolynomialApproximationPass
-    : public PassWrapper<TestMathPolynomialApproximationPass,
-                         OperationPass<FuncOp>> {
+    : public PassWrapper<TestMathPolynomialApproximationPass, OperationPass<>> {
   TestMathPolynomialApproximationPass() = default;
   TestMathPolynomialApproximationPass(
       const TestMathPolynomialApproximationPass &pass)

diff  --git a/mlir/test/lib/Dialect/MemRef/TestComposeSubView.cpp b/mlir/test/lib/Dialect/MemRef/TestComposeSubView.cpp
index 6431cc4e459ef..89a4e6c7d8a61 100644
--- a/mlir/test/lib/Dialect/MemRef/TestComposeSubView.cpp
+++ b/mlir/test/lib/Dialect/MemRef/TestComposeSubView.cpp
@@ -19,7 +19,7 @@ using namespace mlir;
 
 namespace {
 struct TestComposeSubViewPass
-    : public PassWrapper<TestComposeSubViewPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestComposeSubViewPass, OperationPass<>> {
   StringRef getArgument() const final { return "test-compose-subview"; }
   StringRef getDescription() const final {
     return "Test combining composed subviews";

diff  --git a/mlir/test/lib/Dialect/MemRef/TestMultiBuffer.cpp b/mlir/test/lib/Dialect/MemRef/TestMultiBuffer.cpp
index 2e6ace9968bc5..bf5b2bec95616 100644
--- a/mlir/test/lib/Dialect/MemRef/TestMultiBuffer.cpp
+++ b/mlir/test/lib/Dialect/MemRef/TestMultiBuffer.cpp
@@ -16,7 +16,7 @@ using namespace mlir;
 
 namespace {
 struct TestMultiBufferingPass
-    : public PassWrapper<TestMultiBufferingPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestMultiBufferingPass, OperationPass<>> {
   TestMultiBufferingPass() = default;
   TestMultiBufferingPass(const TestMultiBufferingPass &pass)
       : PassWrapper(pass) {}
@@ -37,7 +37,7 @@ struct TestMultiBufferingPass
 
 void TestMultiBufferingPass::runOnOperation() {
   SmallVector<memref::AllocOp> allocs;
-  getOperation().walk(
+  getOperation()->walk(
       [&allocs](memref::AllocOp alloc) { allocs.push_back(alloc); });
   for (memref::AllocOp alloc : allocs)
     (void)multiBuffer(alloc, multiplier);

diff  --git a/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp b/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
index 7a05ba9c71ed1..71854662f1ab7 100644
--- a/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
+++ b/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
@@ -22,8 +22,7 @@ namespace {
 // Extracts fixed-range loops for top-level loop nests with ranges defined in
 // the pass constructor.  Assumes loops are permutable.
 class SimpleParametricLoopTilingPass
-    : public PassWrapper<SimpleParametricLoopTilingPass,
-                         OperationPass<FuncOp>> {
+    : public PassWrapper<SimpleParametricLoopTilingPass, OperationPass<>> {
 public:
   StringRef getArgument() const final {
     return "test-extract-fixed-outer-loops";
@@ -39,8 +38,7 @@ class SimpleParametricLoopTilingPass
   }
 
   void runOnOperation() override {
-    FuncOp func = getOperation();
-    func.walk([this](scf::ForOp op) {
+    getOperation()->walk([this](scf::ForOp op) {
       // Ignore nested loops.
       if (op->getParentRegion()->getParentOfType<scf::ForOp>())
         return;

diff  --git a/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp b/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp
index ff7224a010bcd..77dc5edf8a01b 100644
--- a/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp
+++ b/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp
@@ -31,7 +31,7 @@ static unsigned getNestingDepth(Operation *op) {
 }
 
 class TestLoopUnrollingPass
-    : public PassWrapper<TestLoopUnrollingPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestLoopUnrollingPass, OperationPass<>> {
 public:
   StringRef getArgument() const final { return "test-loop-unrolling"; }
   StringRef getDescription() const final {
@@ -52,9 +52,8 @@ class TestLoopUnrollingPass
   }
 
   void runOnOperation() override {
-    FuncOp func = getOperation();
     SmallVector<scf::ForOp, 4> loops;
-    func.walk([&](scf::ForOp forOp) {
+    getOperation()->walk([&](scf::ForOp forOp) {
       if (getNestingDepth(forOp) == loopDepth)
         loops.push_back(forOp);
     });

diff  --git a/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp b/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp
index 2a2603ad2b18d..46c5c34293f7c 100644
--- a/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp
+++ b/mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp
@@ -21,7 +21,7 @@ using namespace mlir;
 
 namespace {
 struct TestTensorTransforms
-    : public PassWrapper<TestTensorTransforms, OperationPass<FuncOp>> {
+    : public PassWrapper<TestTensorTransforms, OperationPass<>> {
   TestTensorTransforms() = default;
   TestTensorTransforms(const TestTensorTransforms &pass) : PassWrapper(pass) {}
 
@@ -50,14 +50,14 @@ struct TestTensorTransforms
 };
 } // namespace
 
-static void applySplitPaddingPatterns(FuncOp funcOp) {
-  RewritePatternSet patterns(funcOp.getContext());
+static void applySplitPaddingPatterns(Operation *rootOp) {
+  RewritePatternSet patterns(rootOp->getContext());
   tensor::populateSplitPaddingPatterns(patterns);
-  (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(rootOp, std::move(patterns));
 }
 
-static void applyFoldConstantExtractSlicePatterns(FuncOp funcOp) {
-  RewritePatternSet patterns(funcOp.getContext());
+static void applyFoldConstantExtractSlicePatterns(Operation *rootOp) {
+  RewritePatternSet patterns(rootOp->getContext());
   tensor::ControlConstantExtractSliceFusionFn controlFn =
       [](tensor::ExtractSliceOp op) {
         if (!op.source().hasOneUse())
@@ -69,15 +69,15 @@ static void applyFoldConstantExtractSlicePatterns(FuncOp funcOp) {
       };
 
   tensor::populateFoldConstantExtractSlicePatterns(patterns, controlFn);
-  (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(rootOp, std::move(patterns));
 }
 
 void TestTensorTransforms::runOnOperation() {
-  FuncOp func = getOperation();
+  Operation *rootOp = getOperation();
   if (testSplitPaddingPatterns)
-    applySplitPaddingPatterns(func);
+    applySplitPaddingPatterns(rootOp);
   if (testFoldConstantExtractSlice)
-    applyFoldConstantExtractSlicePatterns(func);
+    applyFoldConstantExtractSlicePatterns(rootOp);
 }
 
 namespace mlir {

diff  --git a/mlir/test/lib/IR/TestDiagnostics.cpp b/mlir/test/lib/IR/TestDiagnostics.cpp
index e6bb5f90f57e1..c56d4488ae6d0 100644
--- a/mlir/test/lib/IR/TestDiagnostics.cpp
+++ b/mlir/test/lib/IR/TestDiagnostics.cpp
@@ -18,7 +18,8 @@ using namespace mlir;
 
 namespace {
 struct TestDiagnosticFilterPass
-    : public PassWrapper<TestDiagnosticFilterPass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestDiagnosticFilterPass,
+                         InterfacePass<SymbolOpInterface>> {
   StringRef getArgument() const final { return "test-diagnostic-filter"; }
   StringRef getDescription() const final {
     return "Test diagnostic filtering support.";

diff  --git a/mlir/test/lib/IR/TestDominance.cpp b/mlir/test/lib/IR/TestDominance.cpp
index 23e9e759bee4d..c450bfd855f0c 100644
--- a/mlir/test/lib/IR/TestDominance.cpp
+++ b/mlir/test/lib/IR/TestDominance.cpp
@@ -91,7 +91,7 @@ class DominanceTest {
 };
 
 struct TestDominancePass
-    : public PassWrapper<TestDominancePass, OperationPass<FuncOp>> {
+    : public PassWrapper<TestDominancePass, InterfacePass<SymbolOpInterface>> {
   StringRef getArgument() const final { return "test-print-dominance"; }
   StringRef getDescription() const final {
     return "Print the dominance information for multiple regions.";

diff  --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp
index 20c4ca9e8323f..d1b99d60907a3 100644
--- a/mlir/test/lib/IR/TestFunc.cpp
+++ b/mlir/test/lib/IR/TestFunc.cpp
@@ -7,12 +7,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/FunctionInterfaces.h"
 #include "mlir/Pass/Pass.h"
 
 using namespace mlir;
 
 namespace {
-/// This is a test pass for verifying FuncOp's insertArgument method.
+/// This is a test pass for verifying FunctionOpInterface's insertArgument
+/// method.
 struct TestFuncInsertArg
     : public PassWrapper<TestFuncInsertArg, OperationPass<ModuleOp>> {
   StringRef getArgument() const final { return "test-func-insert-arg"; }
@@ -21,7 +23,7 @@ struct TestFuncInsertArg
     auto module = getOperation();
 
     UnknownLoc unknownLoc = UnknownLoc::get(module.getContext());
-    for (FuncOp func : module.getOps<FuncOp>()) {
+    for (auto func : module.getOps<FunctionOpInterface>()) {
       auto inserts = func->getAttrOfType<ArrayAttr>("test.insert_args");
       if (!inserts || inserts.empty())
         continue;
@@ -47,7 +49,7 @@ struct TestFuncInsertArg
   }
 };
 
-/// This is a test pass for verifying FuncOp's insertResult method.
+/// This is a test pass for verifying FunctionOpInterface's insertResult method.
 struct TestFuncInsertResult
     : public PassWrapper<TestFuncInsertResult, OperationPass<ModuleOp>> {
   StringRef getArgument() const final { return "test-func-insert-result"; }
@@ -57,7 +59,7 @@ struct TestFuncInsertResult
   void runOnOperation() override {
     auto module = getOperation();
 
-    for (FuncOp func : module.getOps<FuncOp>()) {
+    for (auto func : module.getOps<FunctionOpInterface>()) {
       auto inserts = func->getAttrOfType<ArrayAttr>("test.insert_results");
       if (!inserts || inserts.empty())
         continue;
@@ -78,7 +80,8 @@ struct TestFuncInsertResult
   }
 };
 
-/// This is a test pass for verifying FuncOp's eraseArgument method.
+/// This is a test pass for verifying FunctionOpInterface's eraseArgument
+/// method.
 struct TestFuncEraseArg
     : public PassWrapper<TestFuncEraseArg, OperationPass<ModuleOp>> {
   StringRef getArgument() const final { return "test-func-erase-arg"; }
@@ -86,7 +89,7 @@ struct TestFuncEraseArg
   void runOnOperation() override {
     auto module = getOperation();
 
-    for (FuncOp func : module.getOps<FuncOp>()) {
+    for (auto func : module.getOps<FunctionOpInterface>()) {
       BitVector indicesToErase(func.getNumArguments());
       for (auto argIndex : llvm::seq<int>(0, func.getNumArguments()))
         if (func.getArgAttr(argIndex, "test.erase_this_arg"))
@@ -96,7 +99,7 @@ struct TestFuncEraseArg
   }
 };
 
-/// This is a test pass for verifying FuncOp's eraseResult method.
+/// This is a test pass for verifying FunctionOpInterface's eraseResult method.
 struct TestFuncEraseResult
     : public PassWrapper<TestFuncEraseResult, OperationPass<ModuleOp>> {
   StringRef getArgument() const final { return "test-func-erase-result"; }
@@ -106,7 +109,7 @@ struct TestFuncEraseResult
   void runOnOperation() override {
     auto module = getOperation();
 
-    for (FuncOp func : module.getOps<FuncOp>()) {
+    for (auto func : module.getOps<FunctionOpInterface>()) {
       BitVector indicesToErase(func.getNumResults());
       for (auto resultIndex : llvm::seq<int>(0, func.getNumResults()))
         if (func.getResultAttr(resultIndex, "test.erase_this_result"))
@@ -116,20 +119,23 @@ struct TestFuncEraseResult
   }
 };
 
-/// This is a test pass for verifying FuncOp's setType method.
+/// This is a test pass for verifying FunctionOpInterface's setType method.
 struct TestFuncSetType
     : public PassWrapper<TestFuncSetType, OperationPass<ModuleOp>> {
   StringRef getArgument() const final { return "test-func-set-type"; }
-  StringRef getDescription() const final { return "Test FuncOp::setType."; }
+  StringRef getDescription() const final {
+    return "Test FunctionOpInterface::setType.";
+  }
   void runOnOperation() override {
     auto module = getOperation();
     SymbolTable symbolTable(module);
 
-    for (FuncOp func : module.getOps<FuncOp>()) {
+    for (auto func : module.getOps<FunctionOpInterface>()) {
       auto sym = func->getAttrOfType<FlatSymbolRefAttr>("test.set_type_from");
       if (!sym)
         continue;
-      func.setType(symbolTable.lookup<FuncOp>(sym.getValue()).getType());
+      func.setType(
+          symbolTable.lookup<FunctionOpInterface>(sym.getValue()).getType());
     }
   }
 };

diff  --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp
index 4f8d97f6fdbdb..bd8e7f5051912 100644
--- a/mlir/test/lib/IR/TestMatchers.cpp
+++ b/mlir/test/lib/IR/TestMatchers.cpp
@@ -8,6 +8,7 @@
 
 #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
 #include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/FunctionInterfaces.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/Pass/Pass.h"
 
@@ -15,7 +16,8 @@ using namespace mlir;
 
 namespace {
 /// This is a test pass for verifying matchers.
-struct TestMatchers : public PassWrapper<TestMatchers, OperationPass<FuncOp>> {
+struct TestMatchers
+    : public PassWrapper<TestMatchers, InterfacePass<FunctionOpInterface>> {
   void runOnOperation() override;
   StringRef getArgument() const final { return "test-matchers"; }
   StringRef getDescription() const final {
@@ -26,7 +28,7 @@ struct TestMatchers : public PassWrapper<TestMatchers, OperationPass<FuncOp>> {
 
 // This could be done better but is not worth the variadic template trouble.
 template <typename Matcher>
-static unsigned countMatches(FuncOp f, Matcher &matcher) {
+static unsigned countMatches(FunctionOpInterface f, Matcher &matcher) {
   unsigned count = 0;
   f.walk([&count, &matcher](Operation *op) {
     if (matcher.match(op))
@@ -37,7 +39,7 @@ static unsigned countMatches(FuncOp f, Matcher &matcher) {
 
 using mlir::matchers::m_Any;
 using mlir::matchers::m_Val;
-static void test1(FuncOp f) {
+static void test1(FunctionOpInterface f) {
   assert(f.getNumArguments() == 3 && "matcher test funcs must have 3 args");
 
   auto a = m_Val(f.getArgument(0));
@@ -128,7 +130,7 @@ static void test1(FuncOp f) {
                << countMatches(f, p17) << " times\n";
 }
 
-void test2(FuncOp f) {
+void test2(FunctionOpInterface f) {
   auto a = m_Val(f.getArgument(0));
   FloatAttr floatAttr;
   auto p =

diff  --git a/mlir/test/lib/IR/TestOpaqueLoc.cpp b/mlir/test/lib/IR/TestOpaqueLoc.cpp
index 0b24126d062b3..354f5bc997f09 100644
--- a/mlir/test/lib/IR/TestOpaqueLoc.cpp
+++ b/mlir/test/lib/IR/TestOpaqueLoc.cpp
@@ -47,7 +47,8 @@ struct TestOpaqueLoc
       op->setLoc(
           OpaqueLoc::get<MyLocation *>(myLocs.back().get(), &getContext()));
 
-      if (isa<FuncOp>(op) || op->hasTrait<OpTrait::IsTerminator>())
+      if (isa<ModuleOp>(op->getParentOp()) ||
+          op->hasTrait<OpTrait::IsTerminator>())
         return;
 
       OpBuilder builder(op);

diff  --git a/mlir/test/lib/IR/TestVisitors.cpp b/mlir/test/lib/IR/TestVisitors.cpp
index c662d750fa4d1..23e72bb946fcc 100644
--- a/mlir/test/lib/IR/TestVisitors.cpp
+++ b/mlir/test/lib/IR/TestVisitors.cpp
@@ -68,9 +68,9 @@ static void testPureCallbacks(Operation *op) {
 /// Tests erasure callbacks that skip the walk.
 static void testSkipErasureCallbacks(Operation *op) {
   auto skipOpErasure = [](Operation *op) {
-    // Do not erase module and function op. Otherwise there wouldn't be too
-    // much to test in pre-order.
-    if (isa<ModuleOp>(op) || isa<FuncOp>(op))
+    // Do not erase module and module children operations. Otherwise, there
+    // wouldn't be too much to test in pre-order.
+    if (isa<ModuleOp>(op) || isa<ModuleOp>(op->getParentOp()))
       return WalkResult::advance();
 
     llvm::outs() << "Erasing ";
@@ -81,10 +81,10 @@ static void testSkipErasureCallbacks(Operation *op) {
     return WalkResult::skip();
   };
   auto skipBlockErasure = [](Block *block) {
-    // Do not erase module and function blocks. Otherwise there wouldn't be
-    // too much to test in pre-order.
+    // Do not erase module and module children blocks. Otherwise there wouldn't
+    // be too much to test in pre-order.
     Operation *parentOp = block->getParentOp();
-    if (isa<ModuleOp>(parentOp) || isa<FuncOp>(parentOp))
+    if (isa<ModuleOp>(parentOp) || isa<ModuleOp>(parentOp->getParentOp()))
       return WalkResult::advance();
 
     llvm::outs() << "Erasing ";

diff  --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp
index 1f674c782ab39..e2b20f12cc276 100644
--- a/mlir/test/lib/Transforms/TestConstantFold.cpp
+++ b/mlir/test/lib/Transforms/TestConstantFold.cpp
@@ -14,13 +14,13 @@ using namespace mlir;
 namespace {
 /// Simple constant folding pass.
 struct TestConstantFold
-    : public PassWrapper<TestConstantFold, OperationPass<FuncOp>> {
+    : public PassWrapper<TestConstantFold, OperationPass<>> {
   StringRef getArgument() const final { return "test-constant-fold"; }
   StringRef getDescription() const final {
     return "Test operation constant folding";
   }
-  // All constants in the function post folding.
-  SmallVector<Operation *, 8> existingConstants;
+  // All constants in the operation post folding.
+  SmallVector<Operation *> existingConstants;
 
   void foldOperation(Operation *op, OperationFolder &helper);
   void runOnOperation() override;
@@ -37,15 +37,12 @@ void TestConstantFold::foldOperation(Operation *op, OperationFolder &helper) {
   (void)helper.tryToFold(op, processGeneratedConstants);
 }
 
-// For now, we do a simple top-down pass over a function folding constants.  We
-// don't handle conditional control flow, block arguments, folding conditional
-// branches, or anything else fancy.
 void TestConstantFold::runOnOperation() {
   existingConstants.clear();
 
-  // Collect and fold the operations within the function.
+  // Collect and fold the operations within the operation.
   SmallVector<Operation *, 8> ops;
-  getOperation().walk([&](Operation *op) { ops.push_back(op); });
+  getOperation()->walk([&](Operation *op) { ops.push_back(op); });
 
   // Fold the constants in reverse so that the last generated constants from
   // folding are at the beginning. This creates somewhat of a linear ordering to
@@ -56,7 +53,7 @@ void TestConstantFold::runOnOperation() {
     foldOperation(op, helper);
 
   // By the time we are done, we may have simplified a bunch of code, leaving
-  // around dead constants.  Check for them now and remove them.
+  // around dead constants. Check for them now and remove them.
   for (auto *cst : existingConstants) {
     if (cst->use_empty())
       cst->erase();


        


More information about the Mlir-commits mailing list