This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferization] DeallocOp canonicalizer removing memrefs that are never deallocated
ClosedPublic

Authored by maerhart on Aug 1 2023, 9:52 AM.

Details

Summary

This simplifies the op and avoids unnecessary alias checks introduced during the lowering to memref.

Diff Detail

Event Timeline

maerhart created this revision.Aug 1 2023, 9:52 AM
Herald added a project: Restricted Project. · View Herald Transcript
maerhart requested review of this revision.Aug 1 2023, 9:52 AM
springerm accepted this revision.Aug 2 2023, 1:49 AM
springerm added inline comments.
mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
887

To avoid the magic -1, you could make this a SmallVector<Value> and either push the the condition value (if the memref operand is dropped) or {}. Then after creating the new DeallocOp, you can fill in the {} with the new results. I think it makes the pattern a bit simpler because there only one place where the IR is modifed (rewriter.replaceOp(deallocOp, replacements).

893

We should always use the rewriter to modify IR. (rewriter.replaceAllUsesWith)

This revision is now accepted and ready to land.Aug 2 2023, 1:49 AM
maerhart updated this revision to Diff 546459.Aug 2 2023, 7:23 AM
maerhart marked an inline comment as done.

Address comments

maerhart added inline comments.Aug 2 2023, 7:25 AM
mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
893

Right, totally forgot that I'm in a rewrite pattern here. Thanks for the catch!