Fix PR16508.
authorCameron Zwarich <zwarich@apple.com>
Mon, 1 Jul 2013 19:42:46 +0000 (19:42 +0000)
committerCameron Zwarich <zwarich@apple.com>
Mon, 1 Jul 2013 19:42:46 +0000 (19:42 +0000)
commit03fae50cfa5631349fbd47f4c232fc78f5b3b8af
treefee337ff247891746df625b2f783b3ff5b792b74
parentb5f7b0f9780cd1bc6f948b194adfc57176d41711
Fix PR16508.

When phis get lowered, destination copies are inserted using an iterator that is
determined once for all phis in the block, which BuildMI interprets as a request
to insert an instruction directly before the iterator. In the case of a cyclic
phi, source copies may also be inserted directly before this iterator, which can
cause source copies to be inserted before destination copies. The fix is to keep
an iterator to the last phi and then advance it while lowering each phi in order
to insert destination copies directly after the phis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185363 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/PHIElimination.cpp
test/CodeGen/PowerPC/2013-07-01-PHIElimBug.ll [new file with mode: 0644]