diff options
Diffstat (limited to 'llvm/lib/Target/Mips/MipsHazardSchedule.cpp')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsHazardSchedule.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Target/Mips/MipsHazardSchedule.cpp b/llvm/lib/Target/Mips/MipsHazardSchedule.cpp index e35f32035c1..edd176548c5 100644 --- a/llvm/lib/Target/Mips/MipsHazardSchedule.cpp +++ b/llvm/lib/Target/Mips/MipsHazardSchedule.cpp @@ -91,6 +91,14 @@ FunctionPass *llvm::createMipsHazardSchedule() { return new MipsHazardSchedule(); } +// Find the next real instruction from the current position. +static Iter getNextMachineInstr(Iter Position) { + Iter I = Position, E = Position->getParent()->end(); + I = std::find_if_not(I, E, [](const Iter &Insn) { return Insn->isTransient(); }); + assert(I != E); + return I; +} + bool MipsHazardSchedule::runOnMachineFunction(MachineFunction &MF) { const MipsSubtarget *STI = @@ -113,14 +121,14 @@ bool MipsHazardSchedule::runOnMachineFunction(MachineFunction &MF) { bool InsertNop = false; // Next instruction in the basic block. if (std::next(I) != FI->end() && - !TII->SafeInForbiddenSlot(*std::next(I))) { + !TII->SafeInForbiddenSlot(*getNextMachineInstr(std::next(I)))) { InsertNop = true; } else { // Next instruction in the physical successor basic block. for (auto *Succ : FI->successors()) { if (FI->isLayoutSuccessor(Succ) && - Succ->getFirstNonDebugInstr() != Succ->end() && - !TII->SafeInForbiddenSlot(*Succ->getFirstNonDebugInstr())) { + getNextMachineInstr(Succ->begin()) != Succ->end() && + !TII->SafeInForbiddenSlot(*getNextMachineInstr(Succ->begin()))) { InsertNop = true; break; } |

