This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferization] Add bufferization.dealloc canonicalizer to remove unused alloc-dealloc pairs
ClosedPublic

Authored by maerhart on Aug 24 2023, 7:42 AM.

Details

Summary

Deallocation operations where the allocated value is the 'memref' and
'retained' list are currently not supported. This is because when values
are in the retained list, they typically have a use-site at a later
point and another deallocation op exists at that later point to free the
memref then. There alrady exists a canonicalization pattern in the
buffer deallocation simplification pass that removes the allocated value
from the earlier dealloc because it will never be actually deallocated
in that case and thus does not have to be considered in this new
pattern.

Diff Detail

Event Timeline

maerhart created this revision.Aug 24 2023, 7:42 AM
Herald added a project: Restricted Project. · View Herald Transcript
maerhart requested review of this revision.Aug 24 2023, 7:42 AM

memref.alloc ops have a side effect. Do they fold away if if they have no uses? (without this pattern)

memref.alloc ops have a side effect. Do they fold away if if they have no uses? (without this pattern)

Yes they do fold away when running -canonicalize because they only have the allocation side-effect. Should we rely on that instead of manually deleting the alloc op in the pattern?

springerm accepted this revision.Aug 24 2023, 9:00 AM
This revision is now accepted and ready to land.Aug 24 2023, 9:00 AM