diff options
Diffstat (limited to 'llvm/lib/Target/Mips')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp | 23 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsInstrInfo.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsLongBranch.cpp | 4 |
3 files changed, 15 insertions, 20 deletions
diff --git a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp index f5b629846ae..11b4e7dc832 100644 --- a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp +++ b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp @@ -242,7 +242,7 @@ namespace { /// This function searches in the backward direction for an instruction that /// can be moved to the delay slot. Returns true on success. - bool searchBackward(MachineBasicBlock &MBB, Iter Slot) const; + bool searchBackward(MachineBasicBlock &MBB, MachineInstr &Slot) const; /// This function searches MBB in the forward direction for an instruction /// that can be moved to the delay slot. Returns true on success. @@ -594,7 +594,7 @@ bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) { if (MipsCompactBranchPolicy.getValue() != CB_Always || !TII->getEquivalentCompactForm(I)) { - if (searchBackward(MBB, I)) { + if (searchBackward(MBB, *I)) { Filled = true; } else if (I->isTerminator()) { if (searchSuccBBs(MBB, I)) { @@ -659,8 +659,6 @@ template<typename IterTy> bool Filler::searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End, RegDefsUses &RegDU, InspectMemInstr& IM, Iter Slot, IterTy &Filler) const { - bool IsReverseIter = std::is_convertible<IterTy, ReverseIter>::value; - for (IterTy I = Begin; I != End;) { IterTy CurrI = I; ++I; @@ -677,12 +675,6 @@ bool Filler::searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End, if (CurrI->isKill()) { CurrI->eraseFromParent(); - - // This special case is needed for reverse iterators, because when we - // erase an instruction, the iterators are updated to point to the next - // instruction. - if (IsReverseIter && I != End) - I = CurrI; continue; } @@ -722,7 +714,7 @@ bool Filler::searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End, return false; } -bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot) const { +bool Filler::searchBackward(MachineBasicBlock &MBB, MachineInstr &Slot) const { if (DisableBackwardSearch) return false; @@ -731,14 +723,15 @@ bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot) const { MemDefsUses MemDU(Fn->getDataLayout(), &Fn->getFrameInfo()); ReverseIter Filler; - RegDU.init(*Slot); + RegDU.init(Slot); - if (!searchRange(MBB, ReverseIter(Slot), MBB.rend(), RegDU, MemDU, Slot, + MachineBasicBlock::iterator SlotI = Slot; + if (!searchRange(MBB, ++SlotI.getReverse(), MBB.rend(), RegDU, MemDU, Slot, Filler)) return false; - MBB.splice(std::next(Slot), &MBB, std::next(Filler).base()); - MIBundleBuilder(MBB, Slot, std::next(Slot, 2)); + MBB.splice(std::next(SlotI), &MBB, Filler.getReverse()); + MIBundleBuilder(MBB, SlotI, std::next(SlotI, 2)); ++UsefulSlots; return true; } diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.cpp b/llvm/lib/Target/Mips/MipsInstrInfo.cpp index 35ddbf221e8..1332258912a 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.cpp +++ b/llvm/lib/Target/Mips/MipsInstrInfo.cpp @@ -147,14 +147,16 @@ unsigned MipsInstrInfo::InsertBranch(MachineBasicBlock &MBB, unsigned MipsInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { MachineBasicBlock::reverse_iterator I = MBB.rbegin(), REnd = MBB.rend(); - MachineBasicBlock::reverse_iterator FirstBr; unsigned removed; // Skip all the debug instructions. while (I != REnd && I->isDebugValue()) ++I; - FirstBr = I; + if (I == REnd) + return 0; + + MachineBasicBlock::iterator FirstBr = ++I.getReverse(); // Up to 2 branches are removed. // Note that indirect branches are not removed. @@ -162,7 +164,7 @@ unsigned MipsInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { if (!getAnalyzableBrOpc(I->getOpcode())) break; - MBB.erase(I.base(), FirstBr.base()); + MBB.erase((--I).getReverse(), FirstBr); return removed; } diff --git a/llvm/lib/Target/Mips/MipsLongBranch.cpp b/llvm/lib/Target/Mips/MipsLongBranch.cpp index dfb08101956..5eb3e7b01bb 100644 --- a/llvm/lib/Target/Mips/MipsLongBranch.cpp +++ b/llvm/lib/Target/Mips/MipsLongBranch.cpp @@ -157,7 +157,7 @@ void MipsLongBranch::splitMBB(MachineBasicBlock *MBB) { MBB->addSuccessor(Tgt); MF->insert(std::next(MachineFunction::iterator(MBB)), NewMBB); - NewMBB->splice(NewMBB->end(), MBB, (++LastBr).base(), MBB->end()); + NewMBB->splice(NewMBB->end(), MBB, LastBr.getReverse(), MBB->end()); } // Fill MBBInfos. @@ -187,7 +187,7 @@ void MipsLongBranch::initMBBInfo() { if ((Br != End) && !Br->isIndirectBranch() && (Br->isConditionalBranch() || (Br->isUnconditionalBranch() && IsPIC))) - MBBInfos[I].Br = &*(++Br).base(); + MBBInfos[I].Br = &*Br; } } |

