diff --git a/llvm/lib/CodeGen/PHIElimination.cpp b/llvm/lib/CodeGen/PHIElimination.cpp --- a/llvm/lib/CodeGen/PHIElimination.cpp +++ b/llvm/lib/CodeGen/PHIElimination.cpp @@ -515,9 +515,8 @@ // case, we should mark the last such terminator as being the killing // block, not the copy. MachineBasicBlock::iterator KillInst = opBlock.end(); - MachineBasicBlock::iterator FirstTerm = opBlock.getFirstTerminator(); - for (MachineBasicBlock::iterator Term = FirstTerm; - Term != opBlock.end(); ++Term) { + for (MachineBasicBlock::iterator Term = InsertPos; Term != opBlock.end(); + ++Term) { if (Term->readsRegister(SrcReg)) KillInst = Term; } @@ -527,7 +526,7 @@ if (reusedIncoming || !IncomingReg) { // We may have to rewind a bit if we didn't insert a copy this time. - KillInst = FirstTerm; + KillInst = InsertPos; while (KillInst != opBlock.begin()) { --KillInst; if (KillInst->isDebugInstr()) @@ -574,9 +573,8 @@ if (!isLiveOut) { MachineBasicBlock::iterator KillInst = opBlock.end(); - MachineBasicBlock::iterator FirstTerm = opBlock.getFirstTerminator(); - for (MachineBasicBlock::iterator Term = FirstTerm; - Term != opBlock.end(); ++Term) { + for (MachineBasicBlock::iterator Term = InsertPos; + Term != opBlock.end(); ++Term) { if (Term->readsRegister(SrcReg)) KillInst = Term; } @@ -586,7 +584,7 @@ if (reusedIncoming || !IncomingReg) { // We may have to rewind a bit if we didn't just insert a copy. - KillInst = FirstTerm; + KillInst = InsertPos; while (KillInst != opBlock.begin()) { --KillInst; if (KillInst->isDebugInstr())