This is an archive of the discontinued LLVM Phabricator instance.

[IndVars] Fix corner case with unreachable Phi inputs. PR40454
ClosedPublic

Authored by mkazantsev on Feb 11 2019, 4:02 AM.

Details

Summary

Logic in getInsertPointForUses doesn't account for a corner case when Def only
comes to a Phi user from unreachable blocks. In this case, the incoming value may
be arbitrary (and not even available in the input block) and break the loop-related
invariants that are asserted below.

In fact, if we encounter this situation, no IR modification is needed. This Phi will be
simplified away with nearest cleanup.

Diff Detail

Event Timeline

mkazantsev created this revision.Feb 11 2019, 4:02 AM
spatel accepted this revision.Feb 11 2019, 12:50 PM

I'm not familiar with this code, but the change is strictly safer, so LGTM.
You may want to wait a bit before committing in case there are any other comments.

This revision is now accepted and ready to land.Feb 11 2019, 12:50 PM

Moved print after check.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 12 2019, 1:59 AM