This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferization] Add DeallocOp canonicalizer to remove memrefs also present in the retained list
ClosedPublic

Authored by maerhart on Jul 24 2023, 4:17 PM.

Details

Summary

Since memrefs in the retained list will never be deallocated, we can remove them from the list of memrefs to be deallocated. If the list of memrefs to deallocate becomes empty, we can just delete the dealloc operation.

Depends on D156157

Diff Detail

Event Timeline

maerhart created this revision.Jul 24 2023, 4:17 PM
Herald added a project: Restricted Project. · View Herald Transcript
maerhart requested review of this revision.Jul 24 2023, 4:17 PM
springerm added inline comments.Jul 24 2023, 5:24 PM
mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
786

Should this be memref?

825

nit: This should not be necessary.

mlir/test/Dialect/Bufferization/canonicalize.mlir
301

Some of these results should have a use, so that we can check if the result was replaced correctly.

maerhart updated this revision to Diff 544497.Jul 26 2023, 1:37 PM
maerhart marked an inline comment as done.

Address comments

springerm accepted this revision.Jul 26 2023, 1:43 PM
This revision is now accepted and ready to land.Jul 26 2023, 1:43 PM

Sry, forgot to submit these two comments earlier.

mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
786

No, the operation results represent the updated conditions/ownerships. If a value to be deallocated is in the list of values to be retained, it is guaranteed to not be deallocated, thus the condition/ownership stays the same.

825

I changed this a bit, but we need a check here for the case where the result was replaced with the condition operand instead of one of the new results.