This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg][bufferize] Rewrite "write into non-writable memory" detection
ClosedPublic

Authored by springerm on Oct 7 2021, 8:16 PM.

Diff Detail

Event Timeline

springerm created this revision.Oct 7 2021, 8:16 PM
springerm requested review of this revision.Oct 7 2021, 8:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2021, 8:16 PM

The purpose of this revision is to make "write into non-writable memory" conflict detection easier to understand.

In particular, I was thinking for a while that the existing code is missing a case.

%r = tensor.extract_slice %t

where:
* %t aliases in-place write
* %r aliases non-writable buffer

This case is not covered by the existing code. The new one does cover it. After some more thinking, I now believe that it is not possible to construct such an example. However, this was not immediately obvious to me. So for the sake of simplicity/understandability, my suggestion would be to go with something similar to this revision.

The main idea here is that there is a conflict in the case of inplace bufferization if:

  1. Someone writes to (an alias of) opOperand, opResult or to-be-bufferized op writes itself.
  2. And, opOperand or opResult aliases a non-writable buffer.
nicolasvasilache accepted this revision.Oct 8 2021, 2:02 AM

Yes makes sense to isolate the logic and give it a good name.

Could you promote parts of your comment to the commit message ?

Also, if one of the cases here is not expected to be possible to write, how about putting a defensive assertion + TODO on the corresponding branch so that if it shows up in the future we don't silently miss it?

This revision is now accepted and ready to land.Oct 8 2021, 2:02 AM