[Mlir-commits] [mlir] [mlir]use correct iterator when eraseOp (PR #83444)

Congcong Cai llvmlistbot at llvm.org
Thu Feb 29 15:46:49 PST 2024


================
@@ -229,14 +229,14 @@ void RewriterBase::eraseOp(Operation *op) {
       // until the region is empty. (The block graph could be disconnected.)
       while (!r.empty()) {
         SmallVector<Block *> erasedBlocks;
-        for (Block *b : llvm::post_order(&r.front())) {
+        for (Block &b : llvm::reverse(r.getBlocks())) {
----------------
HerrCai0907 wrote:

The reason is some success in block is nullptr, it is already dereferenced.
If we want to keep post order, then we can pass a set including nullptr to avoid visit broken success.

https://github.com/llvm/llvm-project/pull/83444


More information about the Mlir-commits mailing list