This revision introduces the ability to invoke mem2reg as a rewrite pattern. This also modified the canonical mem2reg pass to use the rewrite pattern approach.
Depends on D149825
Differential D149958
[mlir][mem2reg] Add mem2reg rewrite pattern. Moxinilian on May 5 2023, 7:13 AM. Authored by
Details This revision introduces the ability to invoke mem2reg as a rewrite pattern. This also modified the canonical mem2reg pass to use the rewrite pattern approach. Depends on D149825
Diff Detail
Event TimelineComment Actions Is there logic in the existing mem2reg implementation that could possibly be simplified now that we are using a pattern. For example, applyOpPatternsAndFold should cleanup dead blocks by itself AFAIK. Or is the goal to make tryToPromoteMemorySlots completely self contained to make sure it can be used in a pass without running SimplifyRegion or similar after its execution. Comment Actions The intent was the latter yes. Although most of the cleanup in the current implementation is for correctness (except maybe the cleanup in the interfaces): if dead blocks are not properly rewired, the IR structure becomes invalid. So it is definitely necessary if canonicalization is not ran before applying the pattern, which feels like an unnecessary source of fragility. Comment Actions
Ok, I agree that tryToPromoteMemorySlots definitely should not produce invalid IR. Theoretically we could fail if canonicalization did not run but I think it is better to keep the code and have a robust version of mem2reg then!
Comment Actions Address comments.
Comment Actions LGTM modulo one minor comment regarding the debug printout.
|
Usually there is a:
Add the top of the file. After adding it you should be able to simplify the debug print out to: