This is an archive of the discontinued LLVM Phabricator instance.

[mlir] DialectConversion: support erasing blocks
ClosedPublic

Authored by ftynse on May 18 2020, 9:08 AM.

Details

Summary

PatternRewriter has support for erasing a Block from its parent region, but
this feature has not been implemented for ConversionPatternRewriter that needs
to keep track of and be able to undo block actions. Introduce support for
undoing block erasure in the ConversionPatternRewriter by marking all the ops
it contains for erasure and by detaching the block from its parent region. The
detached block is stored in the action description and is not actually deleted
until the rewrites are applied.

Depends On D80134

Diff Detail

Event Timeline

ftynse created this revision.May 18 2020, 9:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2020, 9:08 AM
nicolasvasilache accepted this revision.May 19 2020, 8:23 PM

The part that is modified makes sense to me but I am not qualified to judge how this may break in non-updated places in subtle ways.

This revision is now accepted and ready to land.May 19 2020, 8:23 PM

I am not qualified to judge how this may break in non-updated places in subtle ways.

It should not break any existing code because the entry function to all modifications was llvm_unreachable before this change, so it must not have been called.

This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.May 27 2020, 1:37 PM
mlir/lib/Transforms/DialectConversion.cpp
726

nit: Reverse the if condition here.

Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2020, 3:08 AM

It would be good to mention about eraseOp and eraseBlock at https://mlir.llvm.org/docs/DialectConversion/. I think the need to use these from within rewriter patterns isn't documented anywhere outside of the code.