[flang-commits] [flang] 196c427 - [flang] Convert uses of FunctionPass to OperationPass<FuncOp>

River Riddle via flang-commits flang-commits at lists.llvm.org
Tue Jan 18 20:47:27 PST 2022


Author: River Riddle
Date: 2022-01-18T20:46:44-08:00
New Revision: 196c4279c08d1ef72c2e0196ec69f4a0f8a3a87e

URL: https://github.com/llvm/llvm-project/commit/196c4279c08d1ef72c2e0196ec69f4a0f8a3a87e
DIFF: https://github.com/llvm/llvm-project/commit/196c4279c08d1ef72c2e0196ec69f4a0f8a3a87e.diff

LOG: [flang] Convert uses of FunctionPass to OperationPass<FuncOp>

FunctionPass has been deprecated and is in the process of being removed.

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Transforms/Passes.td
    flang/lib/Optimizer/Transforms/AffineDemotion.cpp
    flang/lib/Optimizer/Transforms/AffinePromotion.cpp
    flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
    flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
    flang/lib/Optimizer/Transforms/RewriteLoop.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td
index ec990476f27db..fa92753e8eea3 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.td
+++ b/flang/include/flang/Optimizer/Transforms/Passes.td
@@ -35,7 +35,7 @@ def AbstractResultOpt : Pass<"abstract-result-opt", "mlir::FuncOp"> {
   ];
 }
 
-def AffineDialectPromotion : FunctionPass<"promote-to-affine"> {
+def AffineDialectPromotion : Pass<"promote-to-affine", "::mlir::FuncOp"> {
   let summary = "Promotes `fir.{do_loop,if}` to `affine.{for,if}`.";
   let description = [{
     Convert fir operations which satisfy affine constraints to the affine
@@ -60,7 +60,7 @@ def AffineDialectPromotion : FunctionPass<"promote-to-affine"> {
   ];
 }
 
-def AffineDialectDemotion : FunctionPass<"demote-affine"> {
+def AffineDialectDemotion : Pass<"demote-affine", "::mlir::FuncOp"> {
   let summary = "Converts `affine.{load,store}` back to fir operations";
   let description = [{
     Affine dialect's default lowering for loads and stores is 
diff erent from
@@ -74,7 +74,7 @@ def AffineDialectDemotion : FunctionPass<"demote-affine"> {
   ];
 }
 
-def ArrayValueCopy : FunctionPass<"array-value-copy"> {
+def ArrayValueCopy : Pass<"array-value-copy", "::mlir::FuncOp"> {
   let summary = "Convert array value operations to memory operations.";
   let description = [{
     Transform the set of array value primitives to a memory-based array
@@ -111,7 +111,7 @@ def CharacterConversion : Pass<"character-conversion"> {
   ];
 }
 
-def CFGConversion : FunctionPass<"cfg-conversion"> {
+def CFGConversion : Pass<"cfg-conversion", "::mlir::FuncOp"> {
   let summary = "Convert FIR structured control flow ops to CFG ops.";
   let description = [{
     Transform the `fir.do_loop`, `fir.if`, and `fir.iterate_while` ops into
@@ -139,7 +139,7 @@ def ExternalNameConversion : Pass<"external-name-interop", "mlir::ModuleOp"> {
   let constructor = "::fir::createExternalNameConversionPass()";
 }
 
-def MemRefDataFlowOpt : FunctionPass<"fir-memref-dataflow-opt"> {
+def MemRefDataFlowOpt : Pass<"fir-memref-dataflow-opt", "::mlir::FuncOp"> {
   let summary =
     "Perform store/load forwarding and potentially removing dead stores.";
   let description = [{

diff  --git a/flang/lib/Optimizer/Transforms/AffineDemotion.cpp b/flang/lib/Optimizer/Transforms/AffineDemotion.cpp
index fa28f0a137360..947c89b015883 100644
--- a/flang/lib/Optimizer/Transforms/AffineDemotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffineDemotion.cpp
@@ -137,9 +137,9 @@ class StdAllocConversion : public mlir::OpRewritePattern<memref::AllocOp> {
 class AffineDialectDemotion
     : public AffineDialectDemotionBase<AffineDialectDemotion> {
 public:
-  void runOnFunction() override {
+  void runOnOperation() override {
     auto *context = &getContext();
-    auto function = getFunction();
+    auto function = getOperation();
     LLVM_DEBUG(llvm::dbgs() << "AffineDemotion: running on function:\n";
                function.print(llvm::dbgs()););
 

diff  --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index eb75a35723ab6..830ed6bbacb50 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -581,10 +581,10 @@ class AffineIfConversion : public mlir::OpRewritePattern<fir::IfOp> {
 class AffineDialectPromotion
     : public AffineDialectPromotionBase<AffineDialectPromotion> {
 public:
-  void runOnFunction() override {
+  void runOnOperation() override {
 
     auto *context = &getContext();
-    auto function = getFunction();
+    auto function = getOperation();
     markAllAnalysesPreserved();
     auto functionAnalysis = AffineFunctionAnalysis(function);
     mlir::OwningRewritePatternList patterns(context);

diff  --git a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
index 90f073e8d97eb..4f9d17526f5c9 100644
--- a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
+++ b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
@@ -770,8 +770,8 @@ namespace {
 class ArrayValueCopyConverter
     : public ArrayValueCopyBase<ArrayValueCopyConverter> {
 public:
-  void runOnFunction() override {
-    auto func = getFunction();
+  void runOnOperation() override {
+    auto func = getOperation();
     LLVM_DEBUG(llvm::dbgs() << "\n\narray-value-copy pass on function '"
                             << func.getName() << "'\n");
     auto *context = &getContext();

diff  --git a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
index 83c15b807a77d..37ff895e85909 100644
--- a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
+++ b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
@@ -94,8 +94,8 @@ class LoadStoreForwarding {
 
 class MemDataFlowOpt : public fir::MemRefDataFlowOptBase<MemDataFlowOpt> {
 public:
-  void runOnFunction() override {
-    mlir::FuncOp f = getFunction();
+  void runOnOperation() override {
+    mlir::FuncOp f = getOperation();
 
     auto *domInfo = &getAnalysis<mlir::DominanceInfo>();
     LoadStoreForwarding<fir::LoadOp, fir::StoreOp> lsf(domInfo);

diff  --git a/flang/lib/Optimizer/Transforms/RewriteLoop.cpp b/flang/lib/Optimizer/Transforms/RewriteLoop.cpp
index 8f13bc2047f9b..5f49be5f46e9e 100644
--- a/flang/lib/Optimizer/Transforms/RewriteLoop.cpp
+++ b/flang/lib/Optimizer/Transforms/RewriteLoop.cpp
@@ -294,7 +294,7 @@ class CfgIterWhileConv : public mlir::OpRewritePattern<fir::IterWhileOp> {
 /// Convert FIR structured control flow ops to CFG ops.
 class CfgConversion : public CFGConversionBase<CfgConversion> {
 public:
-  void runOnFunction() override {
+  void runOnOperation() override {
     auto *context = &getContext();
     mlir::OwningRewritePatternList patterns(context);
     patterns.insert<CfgLoopConv, CfgIfConv, CfgIterWhileConv>(
@@ -306,7 +306,7 @@ class CfgConversion : public CFGConversionBase<CfgConversion> {
     // apply the patterns
     target.addIllegalOp<ResultOp, DoLoopOp, IfOp, IterWhileOp>();
     target.markUnknownOpDynamicallyLegal([](Operation *) { return true; });
-    if (mlir::failed(mlir::applyPartialConversion(getFunction(), target,
+    if (mlir::failed(mlir::applyPartialConversion(getOperation(), target,
                                                   std::move(patterns)))) {
       mlir::emitError(mlir::UnknownLoc::get(context),
                       "error in converting to CFG\n");


        


More information about the flang-commits mailing list