[Mlir-commits] [mlir] f05b705 - [mlir] Fix crash in testNoSkipErasureCallbacks on empty blocks (#183757)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Feb 28 03:15:11 PST 2026


Author: Mehdi Amini
Date: 2026-02-28T11:15:07Z
New Revision: f05b705dd3ce7fad6b30a2bc40dd9bbebf1e6a74

URL: https://github.com/llvm/llvm-project/commit/f05b705dd3ce7fad6b30a2bc40dd9bbebf1e6a74
DIFF: https://github.com/llvm/llvm-project/commit/f05b705dd3ce7fad6b30a2bc40dd9bbebf1e6a74.diff

LOG: [mlir] Fix crash in testNoSkipErasureCallbacks on empty blocks (#183757)

The `noSkipBlockErasure` callback in `testNoSkipErasureCallbacks` called
`block->front().getParentRegion()` to get the parent region of a block.
This dereferences the ilist sentinel node when the block has no
operations, triggering an assertion failure.

Use `block->getParent()` instead, which directly returns the region
containing the block without requiring any operations to be present.

Fixes #183511

Added: 
    

Modified: 
    mlir/test/IR/visitors.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/test/IR/visitors.mlir b/mlir/test/IR/visitors.mlir
index 93380cc96ab0a..24929f9fb6cf1 100644
--- a/mlir/test/IR/visitors.mlir
+++ b/mlir/test/IR/visitors.mlir
@@ -412,3 +412,13 @@ func.func @test_no_skip_block_erasure_block_args(%arg0: i32, %arg1: i32) -> i32
   %0 = arith.addi %arg0, %arg1 : i32
   return %0 : i32
 }
+
+// -----
+
+// Regression test for https://github.com/llvm/llvm-project/issues/183511:
+// testNoSkipErasureCallbacks should not crash when visiting an empty block.
+// The module body block has no ops, so block->front() would previously dereference
+// the ilist sentinel, causing an assertion failure.
+module {}
+// CHECK-LABEL: Block post-order erasures (no skip)
+// CHECK-NEXT:  Erasing block ^bb0 from region 0 from operation 'builtin.module'


        


More information about the Mlir-commits mailing list