[SwitchLowering] Fix the "fixPhis" function.
authorJuergen Ributzka <juergen@apple.com>
Mon, 10 Nov 2014 21:05:27 +0000 (21:05 +0000)
committerJuergen Ributzka <juergen@apple.com>
Mon, 10 Nov 2014 21:05:27 +0000 (21:05 +0000)
commitd0995fb98219a056006645f21833c450c78cc96b
tree99581454d795dc8292003ccd790b4f4d1dbc3353
parent1a66dc74684ddd1f536be10e1afde4f3cec68396
[SwitchLowering] Fix the "fixPhis" function.

Switch statements may have more than one incoming edge into the same BB if they
all have the same value. When the switch statement is converted these incoming
edges are now coming from multiple BBs. Updating all incoming values to be from
a single BB is incorrect and would generate invalid LLVM IR.

The fix is to only update the first occurrence of an incoming value. Switch
lowering will perform subsequent calls to this helper function for each incoming
edge with a new basic block - updating all edges in the process.

This fixes rdar://problem/18916275.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221627 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/LowerSwitch.cpp
test/Transforms/Util/lowerswitch.ll [new file with mode: 0644]