diff options
author | Petar Jovanovic <petar.jovanovic@imgtec.com> | 2016-12-22 19:29:50 +0000 |
---|---|---|
committer | Petar Jovanovic <petar.jovanovic@imgtec.com> | 2016-12-22 19:29:50 +0000 |
commit | 8a4e63994e32e2cf3d7f0ba6fd99fca4e9268183 (patch) | |
tree | 601b5aed94e8511648d34f821a95b17789b7a934 /llvm/lib/Target/Mips/MipsHazardSchedule.cpp | |
parent | 88391248485102a5b1c01f59a1ed9840d91ecddf (diff) | |
download | bcm5719-llvm-8a4e63994e32e2cf3d7f0ba6fd99fca4e9268183.tar.gz bcm5719-llvm-8a4e63994e32e2cf3d7f0ba6fd99fca4e9268183.zip |
[mips] Fix compact branch hazard detection, part 2
Follow up to D27209 fix, this patch now properly handles single transient
instruction in basic block.
Patch by Aleksandar Beserminji.
Differential Revision: https://reviews.llvm.org/D27856
llvm-svn: 290361
Diffstat (limited to 'llvm/lib/Target/Mips/MipsHazardSchedule.cpp')
-rw-r--r-- | llvm/lib/Target/Mips/MipsHazardSchedule.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/llvm/lib/Target/Mips/MipsHazardSchedule.cpp b/llvm/lib/Target/Mips/MipsHazardSchedule.cpp index 47f859cc0a8..31b86124bc8 100644 --- a/llvm/lib/Target/Mips/MipsHazardSchedule.cpp +++ b/llvm/lib/Target/Mips/MipsHazardSchedule.cpp @@ -103,24 +103,23 @@ static Iter getNextMachineInstrInBB(Iter Position) { // Find the next real instruction from the current position, looking through // basic block boundaries. -static Iter getNextMachineInstr(Iter Position) { - if (std::next(Position) == Position->getParent()->end()) { - const MachineBasicBlock * MBB = (&*Position)->getParent(); - for (auto *Succ : MBB->successors()) { - if (MBB->isLayoutSuccessor(Succ)) { - Iter I = Succ->begin(); - Iter Next = getNextMachineInstrInBB(I); - if (Next == Succ->end()) { - return getNextMachineInstr(I); - } else { - return I; - } - } +static Iter getNextMachineInstr(Iter Position, MachineBasicBlock *Parent) { + if (Position == Parent->end()) { + MachineBasicBlock *Succ = Parent->getNextNode(); + if (Succ != nullptr && Parent->isSuccessor(Succ)) { + Position = Succ->begin(); + Parent = Succ; + } else { + llvm_unreachable( + "Should have identified the end of the function earlier!"); } - llvm_unreachable("Should have identified the end of the function earlier!"); } - return getNextMachineInstrInBB(Position); + Iter Instr = getNextMachineInstrInBB(Position); + if (Instr == Parent->end()) { + return getNextMachineInstr(Instr, Parent); + } + return Instr; } bool MipsHazardSchedule::runOnMachineFunction(MachineFunction &MF) { @@ -146,13 +145,7 @@ bool MipsHazardSchedule::runOnMachineFunction(MachineFunction &MF) { bool LastInstInFunction = std::next(I) == FI->end() && std::next(FI) == MF.end(); if (!LastInstInFunction) { - if (std::next(I) != FI->end()) { - // Start looking from the next instruction in the basic block. - Inst = getNextMachineInstr(std::next(I)); - } else { - // Next instruction in the physical successor basic block. - Inst = getNextMachineInstr(I); - } + Inst = getNextMachineInstr(std::next(I), &*FI); } if (LastInstInFunction || !TII->SafeInForbiddenSlot(*Inst)) { |