[Constant Hoisting] Fix multiple entries for the same basic block in PHI nodes.
authorJuergen Ributzka <juergen@apple.com>
Sat, 22 Mar 2014 01:49:27 +0000 (01:49 +0000)
committerJuergen Ributzka <juergen@apple.com>
Sat, 22 Mar 2014 01:49:27 +0000 (01:49 +0000)
commit5cfc91c9a524efb027e6a639ef69fd0ca8911389
tree7009d05d638e9155ddccbac48e1ad155cd71c347
parentd47cb57ab88956197c266df3353347eb31790781
[Constant Hoisting] Fix multiple entries for the same basic block in PHI nodes.

A PHI node usually has only one value/basic block pair per incoming basic block.
In the case of a switch statement it is possible that a following PHI node may
have more than one such pair per incoming basic block. E.g.:
%0 = phi i64 [ 123456, %case2 ], [ 654321, %Entry ], [ 654321, %Entry ]
This is valid and the verfier doesn't complain, because both values are the
same.

Constant hoisting materializes the constant for each operand separately and the
value is still the same, but the variable names have changed. As a result the
verfier can't recognize anymore that they are the same value and complains.

This fix adds special update code for PHI node in constant hoisting to prevent
this corner case.

This fixes <rdar://problem/16394449>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204537 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/ConstantHoisting.cpp
test/Transforms/ConstantHoisting/X86/phi.ll