[mlir] harden expensive-checks mode against ops with repeated operands
authorAlex Zinenko <zinenko@google.com>
Fri, 26 May 2023 15:50:59 +0000 (15:50 +0000)
committerAlex Zinenko <zinenko@google.com>
Tue, 30 May 2023 07:53:39 +0000 (07:53 +0000)
commit1d9a1139fd2c29189f2e2b9b149dfbd1a6b931bb
tree58951b098e9228731b474d8df6a433901d986ec3
parentb187215a44f764fe91237321b4f17caf9f434894
[mlir] harden expensive-checks mode against ops with repeated operands

Transform operations may indicate that they may accept and consume
several handles pointing to the same or nested payload entities. The
initial implementation of the expensive-checks mode was simply ignoring
such cases as consuming the second handle would fail the check after the
first handle invalidated it by consuming the same payload. Additional
checks had been added since then, which could now trigger assertions in
the expensive-checks module itself (instead of or in addition to
use-after-free assertions down the road), specifically because the
payload associations for invalidated handles is removed from the state
to enable other kinds of checking.

Rework the handling of transform operations with repeated handles so
use-after-consume is still reported properly if the consumption happened
by a preceding operation, as opposed to the a preceding operand of the
same operation that is still (corretly) ignored if the op requests that.

Depends on: D151560

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D151569
mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
mlir/test/Dialect/Transform/expensive-checks.mlir
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td