This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][memref] Fix findDealloc() to handle > 1 dealloc for the given alloc.
ClosedPublic

Authored by jurahul on Jul 21 2021, 9:11 AM.

Details

Summary
  • Change findDealloc() to return Optional<Operation *> and return None if > 1 dealloc is associated with the given alloc.
  • Add findDeallocs() to return all deallocs associated with the given alloc.
  • Fix current uses of findDealloc() to bail out if > 1 dealloc is found.

Diff Detail

Event Timeline

jurahul created this revision.Jul 21 2021, 9:11 AM
jurahul requested review of this revision.Jul 21 2021, 9:11 AM
mehdi_amini added inline comments.Jul 21 2021, 2:32 PM
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
544

I'd check the first before calling the second findDealloc: early exit before doing useless work :)

mlir/lib/Dialect/MemRef/Utils/MemRefUtils.cpp
39

When I saw the .h, I thought you were keeping this API for efficiency. But seeing the implementation it clearly isn't :)

Is this separate API really worth it?

jurahul added inline comments.Jul 21 2021, 3:01 PM
mlir/lib/Dialect/MemRef/Utils/MemRefUtils.cpp
39

All current uses actually use the second API. May be I should remove the first API (it can be added later when someone needs to look at all deallocations) and make the second one efficient.

jurahul updated this revision to Diff 360657.Jul 21 2021, 5:14 PM

Remove findDeallocs()

jurahul marked 2 inline comments as done.Jul 21 2021, 5:15 PM
mehdi_amini accepted this revision.Jul 21 2021, 5:53 PM
This revision is now accepted and ready to land.Jul 21 2021, 5:53 PM