This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix invalid assertion in ModuleTranslation.cpp
ClosedPublic

Authored by ftynse on Jan 13 2022, 5:29 AM.

Details

Summary

LLVM dialect supports terminators with repeated successor blocks that take
different operands. This cannot be directly expressed in LLVM IR though since
it uses the number of the predecessor block to differentiate values in its PHI
nodes. Therefore, the translation to LLVM IR inserts dummy blocks to forward
arguments in case of repeated succesors with arguments. The insertion works
correctly. However, when connecting PHI nodes to their source values, the
assertion of the insertion having worked correctly was incorrect: it would only
trigger if repeated blocks were adjacent in the successor list (not guaranteed
by anything) and would not check if the successors have operands (no need for
dummy blocks in absence of operands since no PHIs are being created). Change
the assertion to only trigger in case of duplicate successors with operands,
and don't expect them to be adjacent.

Diff Detail

Event Timeline

ftynse created this revision.Jan 13 2022, 5:29 AM
ftynse requested review of this revision.Jan 13 2022, 5:29 AM
wsmoses accepted this revision.Jan 13 2022, 9:19 AM
This revision is now accepted and ready to land.Jan 13 2022, 9:19 AM
This revision was automatically updated to reflect the committed changes.