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 @@ -1270,6 +1270,16 @@ (`[` $variadic^ `]`)? attr-dict }]>; +def FormatTwoVariadicOperandsNoBuildableTypeOp + : TEST_Op<"format_two_variadic_operands_no_buildable_type_op", + [AttrSizedOperandSegments]> { + let arguments = (ins Variadic:$a, + Variadic:$b); + let assemblyFormat = [{ + `(` $a `:` type($a) `)` `->` `(` $b `:` type($b) `)` attr-dict + }]; +} + //===----------------------------------------------------------------------===// // Test SideEffects //===----------------------------------------------------------------------===// 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 @@ -866,6 +866,8 @@ void OperationFormat::genParserVariadicSegmentResolution(Operator &op, OpMethodBody &body) { if (!allOperands && op.getTrait("OpTrait::AttrSizedOperandSegments")) { + if (buildableTypes.empty()) + body << " Builder &builder = parser.getBuilder();\n"; body << " result.addAttribute(\"operand_segment_sizes\", " << "builder.getI32VectorAttr({"; auto interleaveFn = [&](const NamedTypeConstraint &operand) {