Fix bug: 2003-02-27-StoreSinkPHIs.ll
authorChris Lattner <sabre@nondot.org>
Thu, 27 Feb 2003 21:59:36 +0000 (21:59 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 27 Feb 2003 21:59:36 +0000 (21:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5658 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LICM.cpp

index 0febce48230b99a7257fa7890af830f8be6d9d52..534a073abe190bf04d33a54477006545327a8a51 100644 (file)
@@ -437,7 +437,10 @@ void LICM::PromoteValuesInLoop() {
     for (succ_iterator SI = succ_begin(*I), SE = succ_end(*I); SI != SE; ++SI)
       if (!CurLoop->contains(*SI)) {
         // Copy all of the allocas into their memory locations...
-        Instruction *InsertPos = (*SI)->begin();
+        BasicBlock::iterator BI = (*SI)->begin();
+        while (isa<PHINode>(*BI))
+          ++BI;             // Skip over all of the phi nodes in the block...
+        Instruction *InsertPos = BI;
         for (unsigned i = 0, e = PromotedValues.size(); i != e; ++i) {
           // Load from the alloca...
           LoadInst *LI = new LoadInst(PromotedValues[i].first, "", InsertPos);