R600: avoid calling std::next on an iterator that might be end()
authorTim Northover <tnorthover@apple.com>
Fri, 28 Mar 2014 13:52:56 +0000 (13:52 +0000)
committerTim Northover <tnorthover@apple.com>
Fri, 28 Mar 2014 13:52:56 +0000 (13:52 +0000)
This was causing my llc to go into an infinite loop on
CodeGen/R600/address-space.ll (just triggered recently by some allocator
changes).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205005 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/SILowerControlFlow.cpp

index 182f28ba7740fbcc2733e7ccf4f0cd6e7428755b..c2f86964731fd1be7c2a3cb7e50379b675db0ed4 100644 (file)
@@ -439,10 +439,10 @@ bool SILowerControlFlowPass::runOnMachineFunction(MachineFunction &MF) {
        BI != BE; ++BI) {
 
     MachineBasicBlock &MBB = *BI;
-    for (MachineBasicBlock::iterator I = MBB.begin(), Next = std::next(I);
-         I != MBB.end(); I = Next) {
-
+    MachineBasicBlock::iterator I, Next;
+    for (I = MBB.begin(); I != MBB.end(); I = Next) {
       Next = std::next(I);
+
       MachineInstr &MI = *I;
       if (TII->isDS(MI.getOpcode())) {
         NeedM0 = true;