BasicBlock::removePredecessor replaces phi nodes with single entry even if it will generate self-referencing instructions and break SSA form. This patch fixes this behavior.
Logic regarding the change in CloneFunction.cpp:
- We prevent replacing phi nodes in BasicBlock::removePredecessor only in the cases where it will break SSA form.
- Since it was working before, i.e. verifier did not complain, it means that the code was dead. Then, it shouldn't matter if we skip blocks that still have phi nodes.
See example in the lit test in this patch.