[all-commits] [llvm/llvm-project] d4a53f: [mlir] call target materialization more in dialect...

ftynse via All-commits all-commits at lists.llvm.org
Thu Feb 17 01:13:37 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d4a53f3bfa3e29d412e571765a8568bee7da5483
      https://github.com/llvm/llvm-project/commit/d4a53f3bfa3e29d412e571765a8568bee7da5483
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2022-02-17 (Thu, 17 Feb 2022)

  Changed paths:
    M mlir/lib/Transforms/Utils/DialectConversion.cpp
    A mlir/test/Transforms/test-legalize-target-materialization-no-uses.mlir
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/lib/Dialect/Test/TestPatterns.cpp

  Log Message:
  -----------
  [mlir] call target materialization more in dialect conversion

During dialect conversion, target materialization is triggered to create
cast-like operations when a type mismatch occurs between the value that
replaces a rewritten operation and the type that another operations expects as
operands processed by the type conversion. First, a dummy cast is inserted to
make sure the pattern application can proceed. The decision to trigger the
user-provided materialization hook is taken later based on the result of the
dummy cast having uses. However, it only has uses if other patterns constructed
new operations using the casted value as operand. If existing (legal)
operations use the replaced value, they may have not been updated to use the
casted value yet. The conversion infra would then delete the dummy cast first,
and then would replace the uses with now-invalid (null in the bast case) value.
When deciding whether to trigger cast materialization, check for liveness the
uses not only of the casted value, but also of all the values that it replaces.

This was discovered in the finalizing bufferize pass that cleans up
mutually-cancelling casts without touching other operations. It is not
impossible that there are other scenarios where the dialect converison infra
could produce invalid operand uses because of dummy casts erased too eagerly.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D119937




More information about the All-commits mailing list