[mlir][transform] Better debugging facilites for invalid API usage
authorMatthias Springer <springerm@google.com>
Wed, 12 Apr 2023 06:41:40 +0000 (15:41 +0900)
committerMatthias Springer <springerm@google.com>
Wed, 12 Apr 2023 06:49:28 +0000 (15:49 +0900)
commit07fef178e8b0320dcfeaaef26b5a93eb7dfbf833
tree8c6e24ac05853100abd28298cefe90047930c641
parenta3f688422c44519b578f9ae728b955aabe6b494e
[mlir][transform] Better debugging facilites for invalid API usage

This revision adds additional "expensive-checks" checks to the transform dialect that detect the most common cases of:

* Missing `consumesHandle` side effects on transform ops.
* Patterns that remove operations but do not notify the transform dialect.

In essence, these additional checks are looking for dangling pointers to erased payload ops in the transform dialect state and crash the program execution (by dereferencing free'd memory) or triggering an assertion failure. It is recommended to run these extra checks with ASAN. Otherwise, certain failures may not be detected. The ASAN error message can also be used to find the faulty transform op/pattern.

This change also fixes a few faulty transform ops.

Differential Revision: https://reviews.llvm.org/D147447
mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
mlir/lib/Dialect/Transform/IR/TransformOps.cpp
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td