================
@@ -2001,20 +2001,43 @@ void populateFlattenCFGPatterns(RewritePatternSet 
&patterns) {
 }
 
 void CIRFlattenCFGPass::runOnOperation() {
-  RewritePatternSet patterns(&getContext());
-  populateFlattenCFGPatterns(patterns);
-
-  // Collect operations to apply patterns.
-  llvm::SmallVector<Operation *, 16> ops;
-  getOperation()->walk<mlir::WalkOrder::PostOrder>([&](Operation *op) {
-    if (isa<IfOp, ScopeOp, SwitchOp, LoopOpInterface, TernaryOp, 
CleanupScopeOp,
-            TryOp>(op))
-      ops.push_back(op);
-  });
+  RewritePatternSet patternList(&getContext());
+  populateFlattenCFGPatterns(patternList);
+  FrozenRewritePatternSet patterns(std::move(patternList));
+
+  PatternApplicator applicator(patterns);
+  // We need _A_ cost model, and everything here is the same cost-model, so 
this
+  // is effectively a no-op, but necessary to use the PatternApplicator.
+  applicator.applyDefaultCostModel();
+
+  mlir::PatternRewriter rewriter(&getContext());
+
----------------
erichkeane wrote:

Don't like that one too :D  Ok th en.

https://github.com/llvm/llvm-project/pull/211368
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to