Because of the recent change in r211038 there is the possibility of avoiding the creation of Leaf blocks in LowerSwitch when it is detected that they are not needed.
This is ok until there are no PHI nodes involved, but if PHI nodes are involved in target blocks they need to be updated.
This is done by the newLeafBlock method, but this is not called if the optimization implemented in r211038 triggers.
This patch solves this problem.
Thanks to Qwertyuiop
Original discussion about this bug:
You could use firstNonPHI as the end iterator here rather than is isa<PHINode> check if desired. Either is functionally correct.