[all-commits] [llvm/llvm-project] 878950: [mlir][bufferization] Simplify `getBufferType`

Matthias Springer via All-commits all-commits at lists.llvm.org
Wed Aug 16 06:05:19 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 878950b82cb7727361b5ae13ea0326e39c7677fe
      https://github.com/llvm/llvm-project/commit/878950b82cb7727361b5ae13ea0326e39c7677fe
  Author: Matthias Springer <me at m-sp.org>
  Date:   2023-08-16 (Wed, 16 Aug 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td
    M mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
    M mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/test/Dialect/SCF/one-shot-bufferize-invalid.mlir

  Log Message:
  -----------
  [mlir][bufferization] Simplify `getBufferType`

`getBufferType` computes the bufferized type of an SSA value without bufferizing any IR. This is useful for predicting the bufferized type of iter_args of a loop.

To avoid endless recursion (e.g., in the case of "scf.for", the type of the iter_arg depends on the type of init_arg and the type of the yielded value; the type of the yielded value depends on the type of the iter_arg again), `fixedTypes` was used to fall back to "fixed" type. A simpler way is to maintain an "invocation stack". `getBufferType` implementations can then inspect the invocation stack to detect repetitive computations (typically when computing the bufferized type of a block argument).

Also improve error messages in case of inconsistent memory spaces inside of a loop.

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




More information about the All-commits mailing list