This is an archive of the discontinued LLVM Phabricator instance.

[mlir][scf][bufferize] Fix bufferizesToMemoryRead with 0 loop iterations
ClosedPublic

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

Details

Summary

There was a bug in scf.for loop bufferization that could lead to a missing buffer copy (alloc was there, but not the copy).

Depends On D135052

Diff Detail

Event Timeline

springerm created this revision.Oct 2 2022, 7:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2022, 7:20 PM
springerm requested review of this revision.Oct 2 2022, 7:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2022, 7:20 PM
nicolasvasilache requested changes to this revision.Oct 13 2022, 1:08 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
502

This feels too brutal to me.
I'd add a method on loop-like interface that distinguishes whether the loop is statically known to have 0 or at least 1 iteration.
The statically know 0-iteration case should be plumbed through properly in canonicalizers, folding patterns etc.

Then, if we don't statically know there is at least 1 iteration we would return true here to be conservative.

I imagine this would be costly and that the proper solution in the longer term is to have ref counting.

This revision now requires changes to proceed.Oct 13 2022, 1:08 AM
springerm updated this revision to Diff 468581.Oct 18 2022, 8:50 AM

address comments

nicolasvasilache accepted this revision.Oct 24 2022, 5:17 AM
This revision is now accepted and ready to land.Oct 24 2022, 5:17 AM