[Mlir-commits] [mlir] [mlir] Fix crash in testNoSkipErasureCallbacks on empty blocks (PR #183757)
Mehdi Amini
llvmlistbot at llvm.org
Sat Feb 28 02:58:38 PST 2026
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/183757
>From 7db3ebdd62cde2f9e3b5f76e5b61ce7f19184137 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Fri, 27 Feb 2026 07:46:06 -0800
Subject: [PATCH] [mlir] Fix crash in testNoSkipErasureCallbacks on empty
blocks
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
---
mlir/test/IR/visitors.mlir | 10 ++++++++++
1 file changed, 10 insertions(+)
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