Page MenuHomePhabricator

[mlir][bufferize] Do not deallocate allocs that are returned from a block

Authored by springerm on Mar 12 2022, 6:38 AM.



Such IR is rejected by default, but can be allowed with allow-return-memref. In preparation of future refactorings, do not deallocate such buffers.

One-Shot Analysis now gathers information about yielded tensors, so that we know during the actual bufferization whether a newly allocated buffer should be deallocated again. (Otherwise, it will leak. This will be addressed in a subsequent commit that also makes allow-return-memref a non-experimental flag.)

As a cleanup, allow-return-memref is now part of OneShotBufferizationOptions. (It was previously ignored by AlwaysCopyBufferizationState.) Moreover, AlwaysCopyBufferizationState now asserts that create-deallocs is deactivated to prevent surprising behavior.

Depends On D121520

Diff Detail