File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
clang/lib/CIR/Dialect/Transforms Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -61,26 +61,27 @@ struct RemoveRedundantBranches : public OpRewritePattern<BrOp> {
6161 }
6262};
6363
64- struct RemoveEmptyScope
65- : public OpRewritePattern<ScopeOp>::SplitMatchAndRewrite {
66- using SplitMatchAndRewrite::SplitMatchAndRewrite;
64+ struct RemoveEmptyScope : public OpRewritePattern <ScopeOp> {
65+ using OpRewritePattern<ScopeOp>::OpRewritePattern;
6766
68- LogicalResult match (ScopeOp op) const final {
67+ LogicalResult matchAndRewrite (ScopeOp op,
68+ PatternRewriter &rewriter) const final {
6969 // TODO: Remove this logic once CIR uses MLIR infrastructure to remove
7070 // trivially dead operations
71- if (op.isEmpty ())
71+ if (op.isEmpty ()) {
72+ rewriter.eraseOp (op);
7273 return success ();
74+ }
7375
7476 Region ®ion = op.getScopeRegion ();
75- if (region.getBlocks ().front ().getOperations ().size () == 1 )
76- return success (isa<YieldOp>(region.getBlocks ().front ().front ()));
77+ if (region.getBlocks ().front ().getOperations ().size () == 1 &&
78+ isa<YieldOp>(region.getBlocks ().front ().front ())) {
79+ rewriter.eraseOp (op);
80+ return success ();
81+ }
7782
7883 return failure ();
7984 }
80-
81- void rewrite (ScopeOp op, PatternRewriter &rewriter) const final {
82- rewriter.eraseOp (op);
83- }
8485};
8586
8687// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments