diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-03-14 20:44:01 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-03-14 20:44:01 +0000 |
commit | c17ba8a28d2f83dd320745c0c9994464845ac990 (patch) | |
tree | c57ae111d72c5e1250c587cbc83c40127fb27990 /lib | |
parent | 7e526e754481d66a9849e49fb2be19772db91529 (diff) | |
download | external_llvm-c17ba8a28d2f83dd320745c0c9994464845ac990.zip external_llvm-c17ba8a28d2f83dd320745c0c9994464845ac990.tar.gz external_llvm-c17ba8a28d2f83dd320745c0c9994464845ac990.tar.bz2 |
Fix PR2138. Apparently any modification to a std::multimap (including remove entries for a different key) can invalidate multimap iterators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/VirtRegMap.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index 8c6934a..b094412 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/lib/CodeGen/VirtRegMap.cpp @@ -865,12 +865,15 @@ bool LocalSpiller::PrepForUnfoldOpti(MachineBasicBlock &MBB, unsigned UnfoldVR = 0; int FoldedSS = VirtRegMap::NO_STACK_SLOT; VirtRegMap::MI2VirtMapTy::const_iterator I, End; - for (tie(I, End) = VRM.getFoldedVirts(&MI); I != End; ++I) { + for (tie(I, End) = VRM.getFoldedVirts(&MI); I != End; ) { // Only transform a MI that folds a single register. if (UnfoldedOpc) return false; UnfoldVR = I->second.first; VirtRegMap::ModRef MR = I->second.second; + // MI2VirtMap be can updated which invalidate the iterator. + // Increment the iterator first. + ++I; if (VRM.isAssignedReg(UnfoldVR)) continue; // If this reference is not a use, any previous store is now dead. @@ -1380,11 +1383,14 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) { // physical registers that may contain the value of the spilled virtual // register SmallSet<int, 2> FoldedSS; - for (tie(I, End) = VRM.getFoldedVirts(&MI); I != End; ++I) { + for (tie(I, End) = VRM.getFoldedVirts(&MI); I != End; ) { unsigned VirtReg = I->second.first; VirtRegMap::ModRef MR = I->second.second; DOUT << "Folded vreg: " << VirtReg << " MR: " << MR; + // MI2VirtMap be can updated which invalidate the iterator. + // Increment the iterator first. + ++I; int SS = VRM.getStackSlot(VirtReg); if (SS == VirtRegMap::NO_STACK_SLOT) continue; |