aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-03-27 01:27:25 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-03-27 01:27:25 +0000
commit7a963fa8ee2ad90ef456e36c116c046bf2ba8199 (patch)
tree75cfeea971085bbc3aaceee24f92d01725f397f2 /lib
parent7c1483bc6f009318ce66c4d37d1ba930e01a6d13 (diff)
downloadexternal_llvm-7a963fa8ee2ad90ef456e36c116c046bf2ba8199.zip
external_llvm-7a963fa8ee2ad90ef456e36c116c046bf2ba8199.tar.gz
external_llvm-7a963fa8ee2ad90ef456e36c116c046bf2ba8199.tar.bz2
Fix a memory bug: increment an iterator of a deleted machine instr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48853 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/TwoAddressInstructionPass.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index f81f3a7..b7de1cf 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/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;
}
}