diff options
Diffstat (limited to 'lib/Target/Mips/MipsInstrInfo.cpp')
-rw-r--r-- | lib/Target/Mips/MipsInstrInfo.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/Target/Mips/MipsInstrInfo.cpp b/lib/Target/Mips/MipsInstrInfo.cpp index f1526eb2e21..661ead4803b 100644 --- a/lib/Target/Mips/MipsInstrInfo.cpp +++ b/lib/Target/Mips/MipsInstrInfo.cpp @@ -157,24 +157,23 @@ unsigned MipsInstrInfo::removeBranch(MachineBasicBlock &MBB, assert(!BytesRemoved && "code size not handled"); MachineBasicBlock::reverse_iterator I = MBB.rbegin(), REnd = MBB.rend(); - unsigned removed; - - // Skip all the debug instructions. - while (I != REnd && I->isDebugValue()) - ++I; - - if (I == REnd) - return 0; - - MachineBasicBlock::iterator FirstBr = ++I.getReverse(); + unsigned removed = 0; // Up to 2 branches are removed. // Note that indirect branches are not removed. - for (removed = 0; I != REnd && removed < 2; ++I, ++removed) + while (I != REnd && removed < 2) { + // Skip past debug instructions. + if (I->isDebugValue()) { + ++I; + continue; + } if (!getAnalyzableBrOpc(I->getOpcode())) break; - - MBB.erase((--I).getReverse(), FirstBr); + // Remove the branch. + I->eraseFromParent(); + I = MBB.rbegin(); + ++removed; + } return removed; } |