Fix bug where we could iterate off the end of a basic block
authorChris Lattner <sabre@nondot.org>
Mon, 12 May 2003 14:26:38 +0000 (14:26 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 May 2003 14:26:38 +0000 (14:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6116 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/PHIElimination.cpp

index 33537259fb74d44291ffeaf6f6bed064415f130b..e7f4c9f5411b4200dfa8afc71a56846d144aba65 100644 (file)
@@ -76,8 +76,9 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
     // into the phi node destination.
     //
     MachineBasicBlock::iterator AfterPHIsIt = MBB.begin();
-    if (AfterPHIsIt != MBB.end())
-      while ((*AfterPHIsIt)->getOpcode() == TargetInstrInfo::PHI) ++AfterPHIsIt;
+    while (AfterPHIsIt != MBB.end() &&
+           (*AfterPHIsIt)->getOpcode() == TargetInstrInfo::PHI)
+      ++AfterPHIsIt;    // Skip over all of the PHI nodes...
     RegInfo->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC);
     
     // Update live variable information if there is any...