[Mlir-commits] [mlir] 6677477 - Verify number of result types in generated builder.
Sean Silva
llvmlistbot at llvm.org
Fri Mar 27 20:06:10 PDT 2020
Author: Sean Silva
Date: 2020-03-27T20:05:42-07:00
New Revision: 66774771903a0d32e9909e0d40d6f9b1e51b43c0
URL: https://github.com/llvm/llvm-project/commit/66774771903a0d32e9909e0d40d6f9b1e51b43c0
DIFF: https://github.com/llvm/llvm-project/commit/66774771903a0d32e9909e0d40d6f9b1e51b43c0.diff
LOG: Verify number of result types in generated builder.
Summary: This just bit me and is nasty to debug.
Differential Revision: https://reviews.llvm.org/D76888
Added:
Modified:
mlir/test/mlir-tblgen/op-result.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td
index 76484c8c7fb5..c8bdd15cf2f1 100644
--- a/mlir/test/mlir-tblgen/op-result.td
+++ b/mlir/test/mlir-tblgen/op-result.td
@@ -38,6 +38,10 @@ def OpC : NS_Op<"three_normal_result_op", []> {
// 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);
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 47eef13ad586..f262f12ddf2d 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -702,6 +702,11 @@ void OpEmitter::genSeparateArgParamBuilder() {
}
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;
};
More information about the Mlir-commits
mailing list