Skip to content

Commit a2ca2f3

Browse files
committed
[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.
1 parent 9d06e08 commit a2ca2f3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff 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 &region = 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
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)