mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user