This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Correct block merge bug
ClosedPublic

Authored by wsmoses on Nov 18 2020, 3:05 PM.

Details

Summary

Block merging in MLIR will incorrectly merge blocks with operations whose values are used outside of that block. This change forbids this behavior and provides a test where it is illegal to perform such a merge.

Diff Detail

Event Timeline

wsmoses created this revision.Nov 18 2020, 3:05 PM
wsmoses requested review of this revision.Nov 18 2020, 3:05 PM
wsmoses updated this revision to Diff 306238.Nov 18 2020, 3:07 PM

Add test comments.

LGTM, forwarding to @rriddle as I am not very familiar with this code.

mlir/test/Transforms/canonicalize-block-merge.mlir
177

What is the thing that handles them?

Also ultra-nit: terminate sentences with a dot.

232

Nit: can we sink this down to the line that has the call?

wsmoses updated this revision to Diff 306417.Nov 19 2020, 8:05 AM

Fix documentation nits

wsmoses marked 2 inline comments as done.Nov 19 2020, 8:13 AM
wsmoses added inline comments.
mlir/test/Transforms/canonicalize-block-merge.mlir
177

Added full-stop. Unsure where back edges are handled. This test, however, accidentally exhibited the same bug and had to be modified as a result. It now just tests for back edges and does not in the case a value is used externally (the portion we modified and checked by new test).

rriddle accepted this revision.Nov 19 2020, 12:12 PM

This bug should only manifest when one of the blocks dominates the other, but we don't have access to DominanceInfo to check that easily right now though. Can you add a TODO that we can allow this merging when we can check the dominance?

mlir/lib/Transforms/Utils/RegionUtils.cpp
522

You can remove the functionality for newOpsToReplace/opsToReplace for now as well.

This revision is now accepted and ready to land.Nov 19 2020, 12:12 PM
wsmoses updated this revision to Diff 306702.Nov 20 2020, 8:42 AM
wsmoses marked an inline comment as done.

Remove "ops to merge" and add TODO

This revision was automatically updated to reflect the committed changes.