OSDN Git Service

Remove function Filler::isDelayFiller. Check if I is the same instruction that
authorAkira Hatanaka <ahatanaka@mips.com>
Wed, 5 Oct 2011 01:30:09 +0000 (01:30 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Wed, 5 Oct 2011 01:30:09 +0000 (01:30 +0000)
filled the last delay slot visited.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141151 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MipsDelaySlotFiller.cpp

index 3c5f431..690f4ff 100644 (file)
@@ -41,6 +41,7 @@ namespace {
 
     TargetMachine &TM;
     const TargetInstrInfo *TII;
+    MachineBasicBlock::iterator LastFiller;
 
     static char ID;
     Filler(TargetMachine &tm)
@@ -92,6 +93,8 @@ namespace {
 bool Filler::
 runOnMachineBasicBlock(MachineBasicBlock &MBB) {
   bool Changed = false;
+  LastFiller = MBB.end();
+
   for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I)
     if (I->getDesc().hasDelaySlot()) {
       ++FilledSlots;
@@ -106,7 +109,9 @@ runOnMachineBasicBlock(MachineBasicBlock &MBB) {
       else 
         BuildMI(MBB, llvm::next(I), I->getDebugLoc(), TII->get(Mips::NOP));
 
-      ++I; // Skip instruction that has just been moved to delay slot.
+      // Record the filler instruction that filled the delay slot.
+      // The instruction after it will be visited in the next iteration.
+      LastFiller = ++I;
      }
   return Changed;
 
@@ -149,7 +154,7 @@ bool Filler::findDelayInstr(MachineBasicBlock &MBB,
     if (I->hasUnmodeledSideEffects()
         || I->isInlineAsm()
         || I->isLabel()
-        || isDelayFiller(MBB, I)
+        || I == LastFiller
         || I->getDesc().isPseudo()
         //
         // Should not allow:
@@ -264,12 +269,3 @@ bool Filler::IsRegInSet(SmallSet<unsigned, 32>& RegSet, unsigned Reg) {
 
   return false;
 }
-
-// return true if the candidate is a delay filler.
-bool Filler::isDelayFiller(MachineBasicBlock &MBB,
-                           MachineBasicBlock::iterator candidate) {
-  if (candidate == MBB.begin())
-    return false;
-  const MCInstrDesc &prevdesc = (--candidate)->getDesc();
-  return prevdesc.hasDelaySlot();
-}