This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Erase or clear blocks through ConversionPatternRewriter when applicable
ClosedPublic

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

Details

Summary

Multiple places in the code base were erasing Blocks or operations in them
using in-place modifications (Block::erase or Block::clear) unknown to
ConversionPatternRewriter. These operations could not be undone if the pattern
failed and could lead to inconsistent in-memory state of the IR with dangling
pointers. Use ConversionPatternRewriter::eraseOp and ::eraseBlock instead.

Depends On D80135

Diff Detail

Event Timeline

ftynse created this revision.May 18 2020, 9:09 AM
nicolasvasilache accepted this revision.May 18 2020, 9:50 AM
This revision is now accepted and ready to land.May 18 2020, 9:50 AM
This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.May 27 2020, 1:40 PM
mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
75–76

This was because originally ensureTerminator wasn't tracked, so this could now be removed entirely. The create<AffineTerminatorOp> below would also need to be removed.

ftynse marked 2 inline comments as done.Jun 2 2020, 3:55 AM
ftynse added inline comments.
mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
75–76
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2020, 3:55 AM