From fde21cfa64082ce49f9b92cc485bbd7760800fa8 Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Thu, 9 Dec 2010 17:31:11 +0000 Subject: [PATCH] Fix delay slot filler for non mips1 targets. Patch by Akira Hatanaka llvm-svn: 121376 --- llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp index 9269e7984075..b44a0af2d436 100644 --- a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp +++ b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp @@ -31,7 +31,7 @@ namespace { const TargetInstrInfo *TII; static char ID; - Filler(TargetMachine &tm) + Filler(TargetMachine &tm) : MachineFunctionPass(ID), TM(tm), TII(tm.getInstrInfo()) { } virtual const char *getPassName() const { @@ -55,18 +55,22 @@ namespace { /// Currently, we fill delay slots with NOPs. We assume there is only one /// delay slot per delayed instruction. bool Filler:: -runOnMachineBasicBlock(MachineBasicBlock &MBB) +runOnMachineBasicBlock(MachineBasicBlock &MBB) { bool Changed = false; - for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) - if (TM.getSubtarget().isMips1() && - I->getDesc().hasDelaySlot()) { + for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) { + const TargetInstrDesc& Tid = I->getDesc(); + if (Tid.hasDelaySlot() && + (TM.getSubtarget().isMips1() || + Tid.isCall() || Tid.isBranch() || Tid.isReturn())) { MachineBasicBlock::iterator J = I; ++J; BuildMI(MBB, J, I->getDebugLoc(), TII->get(Mips::NOP)); ++FilledSlots; Changed = true; } + } + return Changed; }