[Mlir-commits] [mlir] [mlir][IR] Set insertion point when erasing an operation (PR #146955)

Markus Böck llvmlistbot at llvm.org
Tue Jul 8 00:49:31 PDT 2025


================
@@ -158,6 +158,12 @@ void RewriterBase::eraseOp(Operation *op) {
   assert(op->use_empty() && "expected 'op' to have no uses");
   auto *rewriteListener = dyn_cast_if_present<Listener>(listener);
 
+  // If the current insertion point is before the erased operation, we adjust
+  // the insertion point to be after the operation.
+  if (getInsertionBlock() == op->getBlock() &&
+      getInsertionPoint() == op->getIterator())
----------------
zero9178 wrote:

```suggestion
  if (getInsertionPoint() == op->getIterator())
```
nit: Just comparing iterators ought to be enough

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


More information about the Mlir-commits mailing list