[llvm-commits] [llvm] r119949 - /llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp
Wesley Peck
peckw at wesleypeck.com
Sun Nov 21 13:36:13 PST 2010
Author: peckw
Date: Sun Nov 21 15:36:12 2010
New Revision: 119949
URL: http://llvm.org/viewvc/llvm-project?rev=119949&view=rev
Log:
Fix an error in the MBlaze delay slot filler where instructions that already
fill a delay slot are moved to fill a different delay slot.
Modified:
llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp
Modified: llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp?rev=119949&r1=119948&r2=119949&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp (original)
+++ llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp Sun Nov 21 15:36:12 2010
@@ -77,7 +77,6 @@
static bool delayHasHazard(MachineBasicBlock::iterator &candidate,
MachineBasicBlock::iterator &slot) {
-
// Loop over all of the operands in the branch instruction
// and make sure that none of them are defined by the
// candidate instruction.
@@ -125,20 +124,35 @@
return false;
}
+static bool isDelayFiller(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator candidate) {
+ if (candidate == MBB.begin())
+ return false;
+
+ TargetInstrDesc brdesc = (--candidate)->getDesc();
+ return (brdesc.hasDelaySlot());
+}
+
static MachineBasicBlock::iterator
-findDelayInstr(MachineBasicBlock &MBB,MachineBasicBlock::iterator &slot) {
- MachineBasicBlock::iterator found = MBB.end();
- for (MachineBasicBlock::iterator I = MBB.begin(); I != slot; ++I) {
- TargetInstrDesc desc = I->getDesc();
- if (desc.hasDelaySlot() || desc.isBranch() ||
- desc.mayLoad() || desc. mayStore() ||
- hasImmInstruction(I) || delayHasHazard(I,slot) ||
- usedBeforeDelaySlot(I,slot)) continue;
+findDelayInstr(MachineBasicBlock &MBB,MachineBasicBlock::iterator slot) {
+ MachineBasicBlock::iterator I = slot;
+ while (true) {
+ if (I == MBB.begin())
+ break;
+
+ --I;
+ TargetInstrDesc desc = I->getDesc();
+ if (desc.hasDelaySlot() || desc.isBranch() || isDelayFiller(MBB,I))
+ break;
+
+ if (desc.mayLoad() || desc.mayStore() || hasImmInstruction(I) ||
+ delayHasHazard(I,slot) || usedBeforeDelaySlot(I,slot))
+ continue;
- found = I;
+ return I;
}
- return found;
+ return MBB.end();
}
/// runOnMachineBasicBlock - Fill in delay slots for the given basic block.
@@ -148,17 +162,16 @@
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I)
if (I->getDesc().hasDelaySlot()) {
- MachineBasicBlock::iterator J = I;
MachineBasicBlock::iterator D = findDelayInstr(MBB,I);
+ MachineBasicBlock::iterator J = I;
- ++J;
++FilledSlots;
Changed = true;
if (D == MBB.end())
- BuildMI(MBB, J, I->getDebugLoc(), TII->get(MBlaze::NOP));
+ BuildMI(MBB, ++J, I->getDebugLoc(), TII->get(MBlaze::NOP));
else
- MBB.splice(J, &MBB, D);
+ MBB.splice(++J, &MBB, D);
}
return Changed;
}
More information about the llvm-commits
mailing list