@@ -612,12 +612,18 @@ bool MipsDelaySlotFiller::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
612
612
if (MipsCompactBranchPolicy.getValue () != CB_Always ||
613
613
!TII->getEquivalentCompactForm (I)) {
614
614
if (searchBackward (MBB, *I)) {
615
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : found instruction for delay slot"
616
+ " in backwards search.\n " );
615
617
Filled = true ;
616
618
} else if (I->isTerminator ()) {
617
619
if (searchSuccBBs (MBB, I)) {
618
620
Filled = true ;
621
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : found instruction for delay slot"
622
+ " in successor BB search.\n " );
619
623
}
620
624
} else if (searchForward (MBB, I)) {
625
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : found instruction for delay slot"
626
+ " in forwards search.\n " );
621
627
Filled = true ;
622
628
}
623
629
}
@@ -662,6 +668,8 @@ bool MipsDelaySlotFiller::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
662
668
}
663
669
664
670
// Bundle the NOP to the instruction with the delay slot.
671
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE << " : could not fill delay slot for " ;
672
+ I->dump ());
665
673
BuildMI (MBB, std::next (I), I->getDebugLoc (), TII->get (Mips::NOP));
666
674
MIBundleBuilder (MBB, I, std::next (I, 2 ));
667
675
++FilledSlots;
@@ -679,13 +687,19 @@ bool MipsDelaySlotFiller::searchRange(MachineBasicBlock &MBB, IterTy Begin,
679
687
for (IterTy I = Begin; I != End;) {
680
688
IterTy CurrI = I;
681
689
++I;
682
-
690
+ LLVM_DEBUG ( dbgs () << DEBUG_TYPE " : checking instruction: " ; CurrI-> dump ());
683
691
// skip debug value
684
- if (CurrI->isDebugInstr ())
692
+ if (CurrI->isDebugInstr ()) {
693
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : ignoring debug instruction: " ;
694
+ CurrI->dump ());
685
695
continue ;
696
+ }
686
697
687
- if (terminateSearch (*CurrI))
698
+ if (terminateSearch (*CurrI)) {
699
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : should terminate search: " ;
700
+ CurrI->dump ());
688
701
break ;
702
+ }
689
703
690
704
assert ((!CurrI->isCall () && !CurrI->isReturn () && !CurrI->isBranch ()) &&
691
705
" Cannot put calls, returns or branches in delay slot." );
@@ -731,6 +745,9 @@ bool MipsDelaySlotFiller::searchRange(MachineBasicBlock &MBB, IterTy Begin,
731
745
continue ;
732
746
733
747
Filler = CurrI;
748
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : found instruction for delay slot: " ;
749
+ CurrI->dump ());
750
+
734
751
return true ;
735
752
}
736
753
@@ -751,8 +768,11 @@ bool MipsDelaySlotFiller::searchBackward(MachineBasicBlock &MBB,
751
768
752
769
MachineBasicBlock::iterator SlotI = Slot;
753
770
if (!searchRange (MBB, ++SlotI.getReverse (), MBB.rend (), RegDU, MemDU, Slot,
754
- Filler))
771
+ Filler)) {
772
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : could not find instruction for delay "
773
+ " slot using backwards search.\n " );
755
774
return false ;
775
+ }
756
776
757
777
MBB.splice (std::next (SlotI), &MBB, Filler.getReverse ());
758
778
MIBundleBuilder (MBB, SlotI, std::next (SlotI, 2 ));
@@ -772,8 +792,11 @@ bool MipsDelaySlotFiller::searchForward(MachineBasicBlock &MBB,
772
792
773
793
RegDU.setCallerSaved (*Slot);
774
794
775
- if (!searchRange (MBB, std::next (Slot), MBB.end (), RegDU, NM, Slot, Filler))
795
+ if (!searchRange (MBB, std::next (Slot), MBB.end (), RegDU, NM, Slot, Filler)) {
796
+ LLVM_DEBUG (dbgs () << DEBUG_TYPE " : could not find instruction for delay "
797
+ " slot using forwards search.\n " );
776
798
return false ;
799
+ }
777
800
778
801
MBB.splice (std::next (Slot), &MBB, Filler);
779
802
MIBundleBuilder (MBB, Slot, std::next (Slot, 2 ));
0 commit comments