[mlir] Harden verifiers for DMA ops
authorAlex Zinenko <zinenko@google.com>
Tue, 5 May 2020 12:09:35 +0000 (14:09 +0200)
committerAlex Zinenko <zinenko@google.com>
Tue, 5 May 2020 18:40:41 +0000 (20:40 +0200)
commit9d273c0ef032445402c332ff7c896d661fca5747
treefb6e8a9c0beedb5f15fa8a92a8a2f96b8f347915
parent0195b3a9098eba9349f4291606581669b2bef548
[mlir] Harden verifiers for DMA ops

DMA operation classes in the Standard dialect (`DmaStartOp` and `DmaWaitOp`)
provide helper functions that make numerous assumptions about the number and
order of operands, and about their types. However, these assumptions were not
checked in the verifier, leading to assertion failures or crashes when helper
functions were used on ill-formed ops. Some of the assuptions were checked in
the custom parser (and thus could not check assumption violations in ops
constructed programmatically, e.g., during rewrites) and others were not
checked at all. Introduce the verifiers for all these assumptions and drop
unnecessary checks in the parser that are now covered by the verifier.

Addresses PR45560.

Differential Revision: https://reviews.llvm.org/D79408
mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/test/IR/invalid-ops.mlir