[Mlir-commits] [mlir] [mlir][test-ir-visitors] Fix noSkipBlockErasure for blocks providing global context (PR #181320)

Matthias Springer llvmlistbot at llvm.org
Mon Feb 16 23:17:50 PST 2026


================
@@ -184,6 +184,24 @@ static void testNoSkipErasureCallbacks(Operation *op) {
       llvm::outs() << "Erasing ";
       printBlock(block);
       llvm::outs() << "\n";
+
+      // Only drop uses from operations within the same parent block holding
+      // operation. This avoids erasing operations with their uses still intact
+      // and eliminates such crashes.
+      // Note: We do not drop uses when the parent block holder operation is
+      // different for the use, because this means that this op is a child of
+      // the current blockParentOp and was expected to be visited and erased
+      // first - we should correctly fail here.
+      Operation *blockParentOp = block->getParentOp();
----------------
matthias-springer wrote:

Can we check for "same parent region" instead of "same parent operation"? That should make it more clear that we are dealing with unstructured control flow cases here.

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


More information about the Mlir-commits mailing list