This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix verifier of `RegionBranchOpInterface`
ClosedPublic

Authored by zero9178 on Aug 9 2023, 7:29 AM.

Details

Summary

The verifier incorrectly passed the region number of the predecessor region instead of the successor region to getSuccessorOperands. This went unnoticed since all upstream RegionBranchTerminatorOpInterface implementations did not make use of the index parameter.
Adding an assert to e.g. scf.condition to make sure the index is valid or adding a region terminator that passes different operands to different successors immediately causes the verifier to fail as it suddenly gets incorrect types.

This patch fixes the implementation to correctly pass the successor region index.

Depends on https://reviews.llvm.org/D157506

Diff Detail

Event Timeline

zero9178 created this revision.Aug 9 2023, 7:29 AM
Herald added a project: Restricted Project. · View Herald Transcript
zero9178 requested review of this revision.Aug 9 2023, 7:29 AM
Mogball accepted this revision.Aug 10 2023, 1:38 AM
This revision is now accepted and ready to land.Aug 10 2023, 1:38 AM
Mogball added inline comments.Aug 10 2023, 1:39 AM
mlir/test/IR/test-region-branch-op-verifier.mlir
2

There's no existing test to merge this withj?

zero9178 marked an inline comment as done.Aug 10 2023, 1:43 AM
zero9178 added inline comments.
mlir/test/IR/test-region-branch-op-verifier.mlir
2

I failed to find any tests for region branch op interface :( All changes done on the file have always been tested indirectly by making sure a pass relying on the interface works.
There are no dedicated tests for the verifier as far as I could tell.

This revision was landed with ongoing or failed builds.Aug 10 2023, 3:52 AM
This revision was automatically updated to reflect the committed changes.
zero9178 marked an inline comment as done.