[Mlir-commits] [mlir] [mlir][bufferization] Fix ownership computation of unknown ops (PR #70773)

Martin Erhart llvmlistbot at llvm.org
Tue Oct 31 17:54:21 PDT 2023


maerhart wrote:

What does the deallocation pass do for something like the following and what should it do (I.e., does the pass that lowers the to_tensor have to deal with deallocation of %a or should it assume that it always returns a clone and thus already insert a deallocation). If I remember correctly it currently deallocates %a at the end of the function potentially leading to a use after free. If it always retains memrefs passed to such ops there should only be leaks and no double free  or use after free, but one would need to properly write this down an provide it as an ABI to the user.
I just wanted to say that I didn't really consider it during design and implementation and thus unexpected things might happen.

```
func @f() -> tensor {
  %a = memref.alloc
  %b = to_tensor %a
  return %b
}
```

https://github.com/llvm/llvm-project/pull/70773


More information about the Mlir-commits mailing list