[llvm] r215233 - AArch64: avoid deleting the current iterator in a loop.

Tim Northover tnorthover at apple.com
Fri Aug 8 10:31:52 PDT 2014


Author: tnorthover
Date: Fri Aug  8 12:31:52 2014
New Revision: 215233

URL: http://llvm.org/viewvc/llvm-project?rev=215233&view=rev
Log:
AArch64: avoid deleting the current iterator in a loop.

std::map invalidates the iterator to any element that gets deleted, which means
we can't increment it correctly afterwards. This was causing Darwin test
failures.

Modified:
    llvm/trunk/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp

Modified: llvm/trunk/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp?rev=215233&r1=215232&r2=215233&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp Fri Aug  8 12:31:52 2014
@@ -671,13 +671,14 @@ maybeKillChain(MachineOperand &MO, unsig
   } else if (MO.isRegMask()) {
 
     for (auto I = ActiveChains.begin(), E = ActiveChains.end();
-         I != E; ++I) {
+         I != E;) {
       if (MO.clobbersPhysReg(I->first)) {
         DEBUG(dbgs() << "Kill (regmask) seen for chain "
               << TRI->getName(I->first) << "\n");
         I->second->setKill(MI, Idx, /*Immutable=*/true);
-        ActiveChains.erase(I);
-      }
+        ActiveChains.erase(I++);
+      } else
+        ++I;
     }
 
   }





More information about the llvm-commits mailing list