This is an archive of the discontinued LLVM Phabricator instance.

[mlir:bytecode] Support lazy loading dynamically isolated regions
ClosedPublic

Authored by rriddle on Jul 24 2023, 8:45 PM.

Details

Summary

We currently only support lazy loading for regions that
statically implement the IsolatedFromAbove trait, but that
limits the amount of operations that can be lazily loaded. This review
lifts that restriction by computing which operations have isolated
regions when numbering, allowing any operation to be lazily loaded
as long as it doesn't use values defined above.

Diff Detail

Event Timeline

rriddle created this revision.Jul 24 2023, 8:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 8:45 PM
rriddle requested review of this revision.Jul 24 2023, 8:45 PM
mehdi_amini added inline comments.Jul 24 2023, 9:10 PM
mlir/lib/Bytecode/Writer/IRNumbering.cpp
190

Isn't this redundant with the numbering optional isIsolatedFromAbove?
If numbering->isIsolatedFromAbove has a value, it means we already know and shouldCheckIsolation should be false.

194

Some description of what's happening below would be useful, it's a non-trivial algorithm.
I would document the invariants around the stack as well

200

This if the longest, can we put it at the end and check the other conditions with an early return (and reduce indentation)

rriddle updated this revision to Diff 543847.Jul 25 2023, 12:01 AM
rriddle edited the summary of this revision. (Show Details)
rriddle marked 2 inline comments as done.
rriddle added inline comments.Jul 25 2023, 12:02 AM
mlir/lib/Bytecode/Writer/IRNumbering.cpp
190

Not exactly. isIsolatedFromAbove applies for the current op, but this flag is if the current op or any of its parents still need checking. We can only avoid checking if we know the current region and all of the parents have been resolved, otherwise we might miss checking something like:

top.op {
  %value = ...
  middle.op {
    %value2 = ...
    inner.op {
      // Here we mark inner.op as not isolated (but not middle.op yet)
      use %value2 

      // Here inner.op is already known to be non-isolated, but middle.op is now also
      // discovered to be non-isolated.
      use %value
    }
  }
}
mehdi_amini accepted this revision.Jul 25 2023, 12:16 AM
mehdi_amini added inline comments.
mlir/lib/Bytecode/Writer/IRNumbering.cpp
190

Tricky... Can you add this comment in the code?

Edit: Oh.. you did already! :)

This revision is now accepted and ready to land.Jul 25 2023, 12:16 AM
This revision was landed with ongoing or failed builds.Jul 25 2023, 3:57 PM
This revision was automatically updated to reflect the committed changes.