summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-11-01 04:49:29 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-11-01 04:49:29 +0000
commit049260d9e2f72d650d97167e1ab451384e32b014 (patch)
treeb7f75e895da2bcbcdbb30f9966486e8c1d672ce1 /lib
parent597362a54bf4bb8de5538b4a1d97c618b18a023c (diff)
downloadllvm-049260d9e2f72d650d97167e1ab451384e32b014.tar.gz
llvm-049260d9e2f72d650d97167e1ab451384e32b014.tar.bz2
llvm-049260d9e2f72d650d97167e1ab451384e32b014.tar.xz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
index 288fe68097..0cc969b01d 100644
--- a/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -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);