This is an archive of the discontinued LLVM Phabricator instance.

[LowerSwitch] Fixed faulty PHI node in switch default block
ClosedPublic

Authored by Ka-Ka on May 22 2018, 9:30 AM.

Details

Summary

When lowerswitch find out that the switch default branch is not
reachable it remove the old default and replace it with the most
popular block from the cases, but it forget to update the PHI
nodes in the default block.

Diff Detail

Event Timeline

Ka-Ka created this revision.May 22 2018, 9:30 AM
Ka-Ka updated this revision to Diff 148685.May 25 2018, 4:11 PM

Reduced the size of the testcase.

arsenm added a comment.Jun 4 2018, 4:20 AM

Shouldn't there be a removePredecessor call somewhere that takes care of this?

Ka-Ka updated this revision to Diff 149740.Jun 4 2018, 6:01 AM

Shouldn't there be a removePredecessor call somewhere that takes care of this?

Correct. Patch updated with call to removePredecessor.

Ka-Ka updated this revision to Diff 152092.Jun 20 2018, 8:14 AM

Fixed another case when PHI nodes are not correctly updated.
This time it is when switch is replaced with a single branch.

arsenm accepted this revision.Jul 9 2018, 3:06 AM

LGTM with nit

lib/Transforms/Utils/LowerSwitch.cpp
531

i should be capitalized

This revision is now accepted and ready to land.Jul 9 2018, 3:06 AM
This revision was automatically updated to reflect the committed changes.