diff --git a/mlir/test/IR/region.mlir b/mlir/test/IR/region.mlir --- a/mlir/test/IR/region.mlir +++ b/mlir/test/IR/region.mlir @@ -81,3 +81,23 @@ "test.unregistered_without_terminator"() ( { ^bb0: // no predecessors }) : () -> () + +// ----- + +// CHECK: test.single_no_terminator_op +"test.single_no_terminator_op"() ( + { + func @foo1() { return } + func @foo2() { return } + } +) : () -> () + +// CHECK: test.variadic_no_terminator_op +"test.variadic_no_terminator_op"() ( + { + func @foo1() { return } + }, + { + func @foo2() { return } + } +) : () -> () diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -333,6 +333,22 @@ let regions = (region SizedRegion<2>:$my_region, SizedRegion<1>); } +//===----------------------------------------------------------------------===// +// NoTerminator Operation +//===----------------------------------------------------------------------===// + +def SingleNoTerminatorOp : TEST_Op<"single_no_terminator_op", GraphRegionNoTerminator.traits> { + let regions = (region SizedRegion<1>:$my_region); + + let assemblyFormat = "attr-dict `:` $my_region"; +} + +def VariadicNoTerminatorOp : TEST_Op<"variadic_no_terminator_op", GraphRegionNoTerminator.traits> { + let regions = (region VariadicRegion>:$my_regions); + + let assemblyFormat = "attr-dict `:` $my_regions"; +} + //===----------------------------------------------------------------------===// // Test Call Interfaces //===----------------------------------------------------------------------===// diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -695,7 +695,7 @@ /// {0}: The name of the region list. const char *regionListEnsureSingleBlockParserCode = R"( for (auto ®ion : {0}Regions) - if (region.empty()) *{0}Region.emplaceBlock(); + if (region->empty()) region->emplaceBlock(); )"; /// The code snippet used to generate a parser call for an optional region.