This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add MemoryEffects::Allocate to memref::CloneOp
ClosedPublic

Authored by Hardcode84 on Jun 26 2021, 3:09 AM.

Details

Summary

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).

Diff Detail

Event Timeline

Hardcode84 created this revision.Jun 26 2021, 3:09 AM
Hardcode84 requested review of this revision.Jun 26 2021, 3:09 AM
mehdi_amini accepted this revision.Jun 27 2021, 6:27 PM
This revision is now accepted and ready to land.Jun 27 2021, 6:27 PM
This revision was automatically updated to reflect the committed changes.