[Mlir-commits] [clang] [llvm] [mlir] [mlir] Don't assume non-erased DenseMap entries remain valid after erase. NFC (PR #199365)

Jakub Kuderski llvmlistbot at llvm.org
Sat May 23 16:07:17 PDT 2026


================
@@ -345,8 +345,15 @@ LogicalResult bufferization::bufferizeOp(Operation *op,
   if (erasedOps.contains(op))
     return success();
 
-  // Fold all to_buffer(to_tensor(x)) pairs.
-  for (Operation *op : toBufferOps) {
+  // Fold all to_buffer(to_tensor(x)) pairs.  Snapshot the set first:
+  // `foldToBufferToTensorPair` can erase ops, and the rewriter listener
+  // mutates `toBufferOps` from inside that call, which would invalidate
+  // any DenseSet iterator held across it.
+  SmallVector<Operation *> toBufferOpsSnapshot(toBufferOps.begin(),
+                                               toBufferOps.end());
----------------
kuhar wrote:

use to_vector

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


More information about the Mlir-commits mailing list