@@ -210,7 +210,7 @@ namespace {
210
210
template <typename IterTy>
211
211
bool searchRange (MachineBasicBlock &MBB, IterTy Begin, IterTy End,
212
212
RegDefsUses &RegDU, InspectMemInstr &IM,
213
- IterTy &Filler) const ;
213
+ IterTy &Filler, Iter Slot ) const ;
214
214
215
215
// / This function searches in the backward direction for an instruction that
216
216
// / can be moved to the delay slot. Returns true on success.
@@ -612,7 +612,7 @@ FunctionPass *llvm::createMipsDelaySlotFillerPass(MipsTargetMachine &tm) {
612
612
template <typename IterTy>
613
613
bool Filler::searchRange (MachineBasicBlock &MBB, IterTy Begin, IterTy End,
614
614
RegDefsUses &RegDU, InspectMemInstr& IM,
615
- IterTy &Filler) const {
615
+ IterTy &Filler, Iter Slot ) const {
616
616
for (IterTy I = Begin; I != End; ++I) {
617
617
// skip debug value
618
618
if (I->isDebugValue ())
@@ -640,6 +640,15 @@ bool Filler::searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End,
640
640
continue ;
641
641
}
642
642
643
+ bool InMicroMipsMode = TM.getSubtarget <MipsSubtarget>().inMicroMipsMode ();
644
+ const MipsInstrInfo *TII = static_cast <const MipsInstrInfo *>(
645
+ TM.getSubtargetImpl ()->getInstrInfo ());
646
+ unsigned Opcode = (*Slot).getOpcode ();
647
+ if (InMicroMipsMode && TII->GetInstSizeInBytes (&(*I)) == 2 &&
648
+ (Opcode == Mips::JR || Opcode == Mips::PseudoIndirectBranch ||
649
+ Opcode == Mips::PseudoReturn))
650
+ continue ;
651
+
643
652
Filler = I;
644
653
return true ;
645
654
}
@@ -657,7 +666,8 @@ bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot) const {
657
666
658
667
RegDU.init (*Slot);
659
668
660
- if (!searchRange (MBB, ReverseIter (Slot), MBB.rend (), RegDU, MemDU, Filler))
669
+ if (!searchRange (MBB, ReverseIter (Slot), MBB.rend (), RegDU, MemDU, Filler,
670
+ Slot))
661
671
return false ;
662
672
663
673
MBB.splice (std::next (Slot), &MBB, std::next (Filler).base ());
@@ -677,7 +687,7 @@ bool Filler::searchForward(MachineBasicBlock &MBB, Iter Slot) const {
677
687
678
688
RegDU.setCallerSaved (*Slot);
679
689
680
- if (!searchRange (MBB, std::next (Slot), MBB.end (), RegDU, NM, Filler))
690
+ if (!searchRange (MBB, std::next (Slot), MBB.end (), RegDU, NM, Filler, Slot ))
681
691
return false ;
682
692
683
693
MBB.splice (std::next (Slot), &MBB, Filler);
@@ -720,7 +730,8 @@ bool Filler::searchSuccBBs(MachineBasicBlock &MBB, Iter Slot) const {
720
730
IM.reset (new MemDefsUses (MFI));
721
731
}
722
732
723
- if (!searchRange (MBB, SuccBB->begin (), SuccBB->end (), RegDU, *IM, Filler))
733
+ if (!searchRange (MBB, SuccBB->begin (), SuccBB->end (), RegDU, *IM, Filler,
734
+ Slot))
724
735
return false ;
725
736
726
737
insertDelayFiller (Filler, BrMap);
0 commit comments