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 | 84aec09fdb4a4ce9ae30fa84246513f86f484634 (patch) | |
| tree | f80d83380243726f0543198cad410cdb6480c6b6 /llvm/lib/CodeGen | |
| parent | bb8c2406dc24d5db37bc5f5f694f3bf25b2e1527 (diff) | |
| download | bcm5719-llvm-84aec09fdb4a4ce9ae30fa84246513f86f484634.tar.gz bcm5719-llvm-84aec09fdb4a4ce9ae30fa84246513f86f484634.zip | |
Fix PR2138. Apparently any modification to a std::multimap (including remove entries for a different key) can invalidate multimap iterators.
llvm-svn: 48371
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/VirtRegMap.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp index 8c6934aea88..b094412ae85 100644 --- a/llvm/lib/CodeGen/VirtRegMap.cpp +++ b/llvm/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; |

