[all-commits] [llvm/llvm-project] 293064: [mlir] Add MemoryEffects::Allocate to memref::CloneOp

Ivan Butygin via All-commits all-commits at lists.llvm.org
Tue Jun 29 03:40:41 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 293064222a013055cda9240647110f5bcf8e1f31
      https://github.com/llvm/llvm-project/commit/293064222a013055cda9240647110f5bcf8e1f31
  Author: Butygin <ivan.butygin at intel.com>
  Date:   2021-06-29 (Tue, 29 Jun 2021)

  Changed paths:
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/test/Transforms/buffer-deallocation.mlir

  Log Message:
  -----------
  [mlir] Add MemoryEffects::Allocate to memref::CloneOp

Without it BufferDeallocationPass process only CloneOps created during pass itself and ignore all CloneOps that were already present in IR.

For our specific usecase:

```
func @dealloc_existing_clones(%arg0: memref<?x?xf64>, %arg1: memref<?x?xf64>) -> memref<?x?xf64> {
  return %arg0 : memref<?x?xf64>
}
```

Input arguments will be freed immediately after return from function and we want to prolong lifetime for the returned argument.
To achieve this we explicitly add clones to all input memrefs and expect that BufferDeallocationPass will add correct deallocs to them (unnessesary clone+dealloc pairs will be canonicalized away later).

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




More information about the All-commits mailing list