This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferize] Treat certain aliasing-only uses like memory reads
ClosedPublic

Authored by springerm on Oct 2 2022, 7:16 PM.

Details

Summary

This fixes an issue in One-Shot Bufferize that could lead to missing buffer copies in the future. This bug can currently not be triggered because of the order in which ops are analyzed (always bottom-to-top). However, if we consider different traversal orders for the analysis in the future, this bug can cause subtle issues that are difficult to debug.

Example:

%0 = ...
%1 = tensor.insert ... into %0
%2 = tensor.extract_slice %0
tensor.extract %2[...]

In case of a top-to-bottom analysis of the above IR, the tensor.insert is analyzed before the tensor.extract_slice. In that case, the tensor.insert will bufferize in-place because %2 is not yet known to become an alias of %0 (and therefore causing a conflict).

With this change, the tensor.insert will bufferize out-of-place, regardless of the traversal order.

Note: As this bug cannot be triggered with the current traversal order, there is no test case for this change. However, a subsequent change will introduce an improvement to loop buffferization that depends on this change. That change will have a test case that depends on this fix.

Diff Detail

Event Timeline

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

let's please add a test or this because this is load bearing, approving conditioned on that.

This revision is now accepted and ready to land.Oct 13 2022, 12:37 AM
springerm updated this revision to Diff 467654.Oct 13 2022, 6:40 PM

address comments

This revision was landed with ongoing or failed builds.Oct 13 2022, 6:45 PM
This revision was automatically updated to reflect the committed changes.