This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Allow unreachable blocks to violate dominance property.
ClosedPublic

Authored by stephenneuendorffer on May 13 2020, 11:18 PM.

Details

Summary

It is possible for optimizations to create SSA code which violates
the dominance property in unreachable blocks. Equivalently, dominance
computed using normal mechanisms is undefined in unreachable blocks.

See discussion here: https://llvm.discourse.group/t/rfc-allowing-dialects-to-relax-the-ssa-dominance-condition/833/51

This patch only checks the dominance condition inside blocks which are
reachable from the the entry block of their region. Note that the
dominance conditions of regions contained in an unreachable block are
still checked.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald Transcript
stephenneuendorffer edited the summary of this revision. (Show Details)
lattner accepted this revision.May 14 2020, 2:53 PM

This looks great, thank you!

mlir/lib/IR/Verifier.cpp
228

Please run clang format on this in the LLVM Style. You need a space after the 'if' and put the brace below on the same line as the 'else'.

This revision was not accepted when it landed; it landed in state Needs Review.May 15 2020, 10:51 AM
This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.May 27 2020, 12:56 PM
mlir/lib/IR/Dominance.cpp
186

Is there a reason we assume unknown blocks are reachable?

186

(Not that I disagree with your choice here, just checking if you thought about it)

mlir/lib/IR/Verifier.cpp
228

nit: These if/else are big enough that they should have braces.

if (...) {
  ...
  return success();
}

...
return success();
mlir/test/IR/invalid.mlir
1539

nit: align the message with the code line.

1545

nit: Move this expected message above.

mlir/test/IR/parser.mlir
1248

nit: Format these checks like the other tests in this file. Right now this test is really hard to read.