This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferize] Fix missing copy when bufferizing loops

Authored by springerm on Aug 11 2022, 9:05 AM.



Using a loop init_arg inside of the loop is not supported. This change adds a pre-processing pass that resolves such IR with copies.

Diff Detail

Event Timeline

springerm created this revision.Aug 11 2022, 9:05 AM
springerm requested review of this revision.Aug 11 2022, 9:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2022, 9:05 AM
jreiffers accepted this revision.Aug 11 2022, 1:40 PM

Thanks for the quick fix!


You could stop iterating after this. Or consider using llvm::any_of, that way you can get rid of the continue above as well.

You might also get rid of usesInsideRegion completely, if you initialize tensorCopy lazily:

Value tensorCopy;
for (OpOperand &use : ...) {
  if (isProperAncestor && llvm::any_of(...)) {
    if (!tensorCopy) {
      tensorCopy = ...;

Not 100% sure it's nicer though.

This revision is now accepted and ready to land.Aug 11 2022, 1:40 PM
springerm marked an inline comment as done.Aug 12 2022, 1:41 AM
springerm updated this revision to Diff 452105.Aug 12 2022, 1:42 AM

address comments

This revision was landed with ongoing or failed builds.Aug 12 2022, 1:50 AM
This revision was automatically updated to reflect the committed changes.