Author: Michael Liao
Date: 2025-04-02T02:14:17-04:00
New Revision: a2ca2f3f10002da61e9860d0ce11e0272482baba

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

LOG: [CIR] Fix cir-canonicalize pass upstreaming issues. NFC

- Fix typos in 'RemoveEmptyScope' pattern rewriting and combine 'match'
  and 'rewrite' into 'matchAndRewrite' as they are deprecated.

Added: 
    

Modified: 
    clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp 
b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
index 1d2d02312d941..cdac69e66dba3 100644
--- a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
@@ -61,26 +61,27 @@ struct RemoveRedundantBranches : public 
OpRewritePattern<BrOp> {
   }
 };
 
-struct RemoveEmptyScope
-    : public OpRewritePattern<ScopeOp>::SplitMatchAndRewrite {
-  using SplitMatchAndRewrite::SplitMatchAndRewrite;
+struct RemoveEmptyScope : public OpRewritePattern<ScopeOp> {
+  using OpRewritePattern<ScopeOp>::OpRewritePattern;
 
-  LogicalResult match(ScopeOp op) const final {
+  LogicalResult matchAndRewrite(ScopeOp op,
+                                PatternRewriter &rewriter) const final {
     // TODO: Remove this logic once CIR uses MLIR infrastructure to remove
     // trivially dead operations
-    if (op.isEmpty())
+    if (op.isEmpty()) {
+      rewriter.eraseOp(op);
       return success();
+    }
 
     Region &region = op.getScopeRegion();
-    if (region.getBlocks().front().getOperations().size() == 1)
-      return success(isa<YieldOp>(region.getBlocks().front().front()));
+    if (region.getBlocks().front().getOperations().size() == 1 &&
+        isa<YieldOp>(region.getBlocks().front().front())) {
+      rewriter.eraseOp(op);
+      return success();
+    }
 
     return failure();
   }
-
-  void rewrite(ScopeOp op, PatternRewriter &rewriter) const final {
-    rewriter.eraseOp(op);
-  }
 };
 
 
//===----------------------------------------------------------------------===//


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to