diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2008-03-27 01:27:25 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2008-03-27 01:27:25 +0000 |
| commit | 5832410d77c814cde27cb423e7a137a8fe18f274 (patch) | |
| tree | d092694180c80d6aaf1eb4a53e084cc9d8a8f274 /llvm/lib/CodeGen | |
| parent | 8ac07c28340c6f77be17ce5fd564023eeec94f06 (diff) | |
| download | bcm5719-llvm-5832410d77c814cde27cb423e7a137a8fe18f274.tar.gz bcm5719-llvm-5832410d77c814cde27cb423e7a137a8fe18f274.zip | |
Fix a memory bug: increment an iterator of a deleted machine instr.
llvm-svn: 48853
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index f81f3a70fb9..b7de1cfae6b 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -200,7 +200,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::iterator mbbi = MF.begin(), mbbe = MF.end(); mbbi != mbbe; ++mbbi) { for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); - mi != me; ++mi) { + mi != me; ) { + MachineBasicBlock::iterator nmi = next(mi); const TargetInstrDesc &TID = mi->getDesc(); bool FirstTied = true; @@ -298,7 +299,10 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { // then one instruction. Sunk = Sink3AddrInstruction(mbbi, New, regB, mi); mbbi->erase(mi); // Nuke the old inst. - if (!Sunk) mi = New; + if (!Sunk) { + mi = New; + nmi = next(mi); + } ++NumConvertedTo3Addr; // Done with this instruction. break; @@ -337,6 +341,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { DOUT << "\t\trewrite to:\t"; DEBUG(mi->print(*cerr.stream(), &TM)); } + mi = nmi; } } |

