[mlir] add a dynamic user-after-parent-freed transform dialect check
authorAlex Zinenko <zinenko@google.com>
Fri, 10 Jun 2022 09:57:59 +0000 (11:57 +0200)
committerAlex Zinenko <zinenko@google.com>
Fri, 10 Jun 2022 11:05:34 +0000 (13:05 +0200)
commit6403e1b12a61dd7dd2682916afdec6b0a8049c10
treecde195eb988808fc89b08520821b5d35275c544a
parentb73c2280f5f3596c65d6c145abc2c4a97a532fc6
[mlir] add a dynamic user-after-parent-freed transform dialect check

In the transform dialect, a transform IR handle may be pointing to a payload IR
operation that is an ancestor of another payload IR operation pointed to by
another handle. If such a "parent" handle is consumed by a transformation, this
indicates that the associated operation is likely rewritten, which in turn
means that the "child" handle may now be associated with a dangling pointer or
a pointer to a different operation than originally. Add a handle invalidation
mechanism to guard against such situations by reporting errors at runtime.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D127480
mlir/include/mlir/Dialect/Transform/IR/TransformDialect.td
mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
mlir/test/Dialect/Transform/expensive-checks.mlir [new file with mode: 0644]
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td
mlir/test/lib/Dialect/Transform/TestTransformDialectInterpreter.cpp