This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferize] Fix repetitive region conflict detection
ClosedPublic

Authored by springerm on Oct 6 2022, 9:09 PM.

Details

Summary

This fixes a bug where a required buffer copy was not inserted.

Not only written aliases, but also read aliases should be taken into account when computing common enclosing repetitive regions. Furthermore, for writing ops, it does not matter where the destination tensor is defined, but where the op itself is located.

Diff Detail

Event Timeline

springerm created this revision.Oct 6 2022, 9:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 9:09 PM
springerm requested review of this revision.Oct 6 2022, 9:09 PM
jreiffers accepted this revision.Oct 7 2022, 12:24 AM

Thanks for the fix!

mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
434–436

This was probably written for an earlier iteration of the function?

477–485

This can probably be expressed more neatly with all_equal and map_range (+ a filter range below, assuming that optimization is worthwhile).

580

Maybe group all these if (useDominance && ...) checks inside a single if (useDominance) { ... }?

This revision is now accepted and ready to land.Oct 7 2022, 12:24 AM
springerm added inline comments.Oct 7 2022, 3:51 AM
mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
434–436

Addressed in D135438.

These comments still make sense. Expanded them a bit, so they hopefully make more sense.

477–485

This is tricky. I can use all_equal for the writes. But then I still need to call getEnclosingRepetitiveRegion a second time, so that I can compare all reads to that value. Then there's still a special case where usesWrite is empty, so I still need the Optional<Region *>. (Note: The getEnclosingRepetitiveRegion calls are slightly different for reads and writes, apart from the isMemoryWrite.)

580

Addressed in D135438.