From: Tim Northover Date: Fri, 8 Aug 2014 17:31:52 +0000 (+0000) Subject: AArch64: avoid deleting the current iterator in a loop. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1968324efa6e47f5afae17a614625462faf5f125;p=oota-llvm.git 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215233 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp b/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp index 705679b570e..dc8cb32d199 100644 --- a/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp +++ b/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp @@ -671,13 +671,14 @@ maybeKillChain(MachineOperand &MO, unsigned Idx, } 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; } }