[PATCH] D76888: Verify number of result types in generated builder.
Sean Silva via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 26 15:14:51 PDT 2020
silvas created this revision.
silvas added a reviewer: antiagainst.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.
This just bit me and is nasty to debug.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76888
Files:
mlir/test/mlir-tblgen/op-result.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Index: mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
===================================================================
--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -702,6 +702,11 @@
}
return;
case TypeParamKind::Collective:
+ body << " "
+ << "assert(resultTypes.size() "
+ << (op.getNumVariadicResults() == 0 ? "==" : ">=") << " "
+ << (op.getNumResults() - op.getNumVariadicResults())
+ << "u && \"mismatched number of results\");\n";
body << " " << builderOpState << ".addTypes(resultTypes);\n";
return;
};
Index: mlir/test/mlir-tblgen/op-result.td
===================================================================
--- mlir/test/mlir-tblgen/op-result.td
+++ mlir/test/mlir-tblgen/op-result.td
@@ -38,6 +38,10 @@
// CHECK-NEXT: odsState.addTypes(resultType1)
// CHECK-NEXT: odsState.addTypes(z)
+// CHECK: void OpC::build(Builder *odsBuilder, OperationState &odsState, ArrayRef<Type> resultTypes) {
+// CHECK-NEXT: assert(resultTypes.size() == 3u && "mismatched number of results");
+// CHECK-NEXT: odsState.addTypes(resultTypes);
+
def IntegerTypeAttr : TypeAttrBase<"IntegerType", "Integer type attribute">;
def OpD : NS_Op<"type_attr_as_result_type", [FirstAttrDerivedResultType]> {
let arguments = (ins I32:$x, IntegerTypeAttr:$attr, F32Attr:$f32);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76888.252987.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200326/ad9181ea/attachment-0001.bin>
More information about the llvm-commits
mailing list