mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-23 22:23:00 +00:00
Make sure we use the right insertion point when instcombine replaces a PHI with another instruction. (Specifically, don't insert an arbitrary instruction before a PHI.) Fixes PR11275.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143437 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2028,9 +2028,10 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
|
||||
BasicBlock *InstParent = I->getParent();
|
||||
BasicBlock::iterator InsertPos = I;
|
||||
|
||||
if (!isa<PHINode>(Result)) // If combining a PHI, don't insert
|
||||
while (isa<PHINode>(InsertPos)) // middle of a block of PHIs.
|
||||
++InsertPos;
|
||||
// If we replace a PHI with something that isn't a PHI, fix up the
|
||||
// insertion point.
|
||||
if (!isa<PHINode>(Result) && isa<PHINode>(InsertPos))
|
||||
InsertPos = InstParent->getFirstInsertionPt();
|
||||
|
||||
InstParent->getInstList().insert(InsertPos, Result);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user