Page MenuHomePhabricator

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

Authored by mkazantsev on Mon, Feb 11, 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

Repository
rL LLVM

Event Timeline

mkazantsev created this revision.Mon, Feb 11, 4:02 AM
spatel accepted this revision.Mon, Feb 11, 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.Mon, Feb 11, 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 TranscriptTue, Feb 12, 1:59 AM