From e42fac519134d21ad3e7396da5746d27d3f7caab Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 8 Aug 2014 17:31:52 +0000 Subject: [PATCH] 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. llvm-svn: 215233 --- llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp b/llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp index 705679b570e6..dc8cb32d199e 100644 --- a/llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp +++ b/llvm/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; } }