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> {
61
61
}
62
62
};
63
63
64
- struct RemoveEmptyScope
65
- : public OpRewritePattern<ScopeOp>::SplitMatchAndRewrite {
66
- using SplitMatchAndRewrite::SplitMatchAndRewrite;
64
+ struct RemoveEmptyScope : public OpRewritePattern <ScopeOp> {
65
+ using OpRewritePattern<ScopeOp>::OpRewritePattern;
67
66
68
- LogicalResult match (ScopeOp op) const final {
67
+ LogicalResult matchAndRewrite (ScopeOp op,
68
+ PatternRewriter &rewriter) const final {
69
69
// TODO: Remove this logic once CIR uses MLIR infrastructure to remove
70
70
// trivially dead operations
71
- if (op.isEmpty ())
71
+ if (op.isEmpty ()) {
72
+ rewriter.eraseOp (op);
72
73
return success ();
74
+ }
73
75
74
76
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
+ }
77
82
78
83
return failure ();
79
84
}
80
-
81
- void rewrite (ScopeOp op, PatternRewriter &rewriter) const final {
82
- rewriter.eraseOp (op);
83
- }
84
85
};
85
86
86
87
// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments