SROA: Don't insert instructions before a PHI
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 1 Sep 2014 21:20:14 +0000 (21:20 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 1 Sep 2014 21:20:14 +0000 (21:20 +0000)
commite64e7c4634ddc8687533f14c1bb2c89ad99edef1
treeac4c7e2dc77962e41a3572234f7d0fcb25fbf9d9
parenta0b2af46a54dc5a3fd8f27deed78828d1833e97a
SROA: Don't insert instructions before a PHI

SROA may decide that it needs to insert a bitcast and would set it's
insertion point before a PHI.  This will create an invalid module
right quick.

Instead, choose the first insertion point in the basic block that holds
our PHI.

This fixes PR20822.

Differential Revision: http://reviews.llvm.org/D5141

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216891 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/SROA.cpp
test/Transforms/SROA/phi-and-select.ll