[Mlir-commits] [mlir] [mlir][test] Fix RegionYieldOp builder adding a null operand (PR #222633)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Sep 10 05:52:04 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Akun (AkunCube)
<details>
<summary>Changes</summary>
The custom NoOperand build delegate of test::RegionYieldOp forwarded {} to build(), which overload resolution maps to the generated builder taking a single Value parameter, so a null Value was added as an operand. That only explodes once the op is actually created: parsing an op with the `SingleBlockImplicitTerminator` trait whose region lacks a terminator builds the implicit terminator, inserts the null operand and hits a null use-list
access in IROperandBase::insertInto.
Drop the delegate and use an empty builder body like scf.yield, and add a parser error test for the missing-terminator path.
Fixes #<!-- -->221638
---
Full diff: https://github.com/llvm/llvm-project/pull/222633.diff
2 Files Affected:
- (modified) mlir/test/IR/invalid.mlir (+8)
- (modified) mlir/test/lib/Dialect/Test/TestOps.td (+1-3)
``````````diff
diff --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir
index 89077ef0f4736..6e8fd96ffba31 100644
--- a/mlir/test/IR/invalid.mlir
+++ b/mlir/test/IR/invalid.mlir
@@ -699,3 +699,11 @@ func.func @drop_references_on_block_parse_error(){
}) : () -> ()
return
}
+
+// -----
+
+// Auto-constructing a missing implicit terminator must not crash.
+func.func @cse_of_single_block_op_no_terminator() {
+ %0 = test.cse_of_single_block_op inputs() {
+ } // expected-error {{expected ':'}}
+}
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 492cd44833380..3b6a45a58ff94 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -2653,9 +2653,7 @@ def RegionYieldOp : TEST_Op<"region_yield",
let assemblyFormat = [{
$result `:` type($result) attr-dict
}];
- let builders = [OpBuilder<(ins),
- [{ build($_builder, $_state, {}); }]>
- ];
+ let builders = [OpBuilder<(ins), [{ /* nothing to do */ }]>];
}
class BufferBasedOpBase<string mnemonic, list<Trait> traits>
``````````
</details>
https://github.com/llvm/llvm-project/pull/222633
More information about the Mlir-commits
mailing list