mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 09:45:00 +00:00
Use standard pattern for iterate+erase.
Increment the MBB iterator at the top of the loop to properly handle the current (and previous) instructions getting erased. This fixes PR13625. llvm-svn: 162099
This commit is contained in:
parent
d431f3a1f2
commit
476a5d42a7
@ -496,11 +496,11 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
ImmDefMIs.clear();
|
ImmDefMIs.clear();
|
||||||
FoldAsLoadDefReg = 0;
|
FoldAsLoadDefReg = 0;
|
||||||
|
|
||||||
bool First = true;
|
|
||||||
MachineBasicBlock::iterator PMII;
|
|
||||||
for (MachineBasicBlock::iterator
|
for (MachineBasicBlock::iterator
|
||||||
MII = I->begin(), MIE = I->end(); MII != MIE; ) {
|
MII = I->begin(), MIE = I->end(); MII != MIE; ) {
|
||||||
MachineInstr *MI = &*MII;
|
MachineInstr *MI = &*MII;
|
||||||
|
// We may be erasing MI below, increment MII now.
|
||||||
|
++MII;
|
||||||
LocalMIs.insert(MI);
|
LocalMIs.insert(MI);
|
||||||
|
|
||||||
// If there exists an instruction which belongs to the following
|
// If there exists an instruction which belongs to the following
|
||||||
@ -509,7 +509,6 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
MI->isKill() || MI->isInlineAsm() || MI->isDebugValue() ||
|
MI->isKill() || MI->isInlineAsm() || MI->isDebugValue() ||
|
||||||
MI->hasUnmodeledSideEffects()) {
|
MI->hasUnmodeledSideEffects()) {
|
||||||
FoldAsLoadDefReg = 0;
|
FoldAsLoadDefReg = 0;
|
||||||
++MII;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MI->mayStore() || MI->isCall())
|
if (MI->mayStore() || MI->isCall())
|
||||||
@ -521,7 +520,6 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// MI is deleted.
|
// MI is deleted.
|
||||||
LocalMIs.erase(MI);
|
LocalMIs.erase(MI);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
MII = First ? I->begin() : llvm::next(PMII);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,14 +551,9 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
|
|
||||||
// MI is replaced with FoldMI.
|
// MI is replaced with FoldMI.
|
||||||
Changed = true;
|
Changed = true;
|
||||||
PMII = FoldMI;
|
|
||||||
MII = llvm::next(PMII);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
First = false;
|
|
||||||
PMII = MII;
|
|
||||||
++MII;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user