diff options
| author | Uday Bondhugula <bondhugula@google.com> | 2018-10-10 13:11:32 -0700 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 13:27:59 -0700 |
| commit | d05e1f5dd5311debb43eff9434534f775b5fe2c6 (patch) | |
| tree | 2f79070710e27f9bfa8353668c3a8ed559907bcc /mlir | |
| parent | 487cc5061395716465e957803761c572ba5f55e8 (diff) | |
| download | bcm5719-llvm-d05e1f5dd5311debb43eff9434534f775b5fe2c6.tar.gz bcm5719-llvm-d05e1f5dd5311debb43eff9434534f775b5fe2c6.zip | |
Add assert in Operation->printAssembly to check improperly created Op's.
We allow the name of an operation to be different from the name of the
'ConcreteType' op it was instantiated with. This can happen when you sub-class
an existing op and provide a getOperationName for it. Such a situation leads to
an assertion too deep and at a place seeminly unrelated, and typically when the
module is printed with the trace:
printOperation, printAssembly, Op::print, getOperand, dyn_cast<OperationStmt>,
isa. 'isa' will complain about being called on a null pointer, and the null
pointer actually comes from the getAs<> in printAssembly. This should have been
caught in printAssembly.
On another note, it is also weird that we allow setting the op's name to
something independent of the ConcreteType that op was instantiated with - so,
getAs<ConcreteType> will fail since ConcreteType::isClassFor won't succeed on
it.
PiperOrigin-RevId: 216580294
Diffstat (limited to 'mlir')
| -rw-r--r-- | mlir/include/mlir/IR/OpDefinition.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 6fefeaa5159..199adb85b58 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -606,7 +606,10 @@ public: /// This is the hook used by the AsmPrinter to emit this to the .mlir file. /// Op implementations should provide a print method. static void printAssembly(const Operation *op, OpAsmPrinter *p) { - op->getAs<ConcreteType>()->print(p); + auto opPointer = op->getAs<ConcreteType>(); + assert(opPointer && + "op's name does not match name of concrete type instantiated with"); + opPointer->print(p); } /// This is the hook that checks whether or not this instruction is well |

