forked from OSchip/llvm-project
Add debug output to MipsDelaySlotFiller pass
Summary: I was tracking down a code-generation bug in this pass and found that the added output was useful. It is also helpful to find out why a delay slot could not be filled even though there is clearly a valid instruction (which appears to mostly be caused by CFI instructions). Reviewers: atanasyan Reviewed By: atanasyan Subscribers: merge_guards_bot, sdardis, hiraditya, jrtc27, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70940
This commit is contained in:
parent
ba71e84430
commit
0cc4b95985
|
@ -612,12 +612,18 @@ bool MipsDelaySlotFiller::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
|
||||||
if (MipsCompactBranchPolicy.getValue() != CB_Always ||
|
if (MipsCompactBranchPolicy.getValue() != CB_Always ||
|
||||||
!TII->getEquivalentCompactForm(I)) {
|
!TII->getEquivalentCompactForm(I)) {
|
||||||
if (searchBackward(MBB, *I)) {
|
if (searchBackward(MBB, *I)) {
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": found instruction for delay slot"
|
||||||
|
" in backwards search.\n");
|
||||||
Filled = true;
|
Filled = true;
|
||||||
} else if (I->isTerminator()) {
|
} else if (I->isTerminator()) {
|
||||||
if (searchSuccBBs(MBB, I)) {
|
if (searchSuccBBs(MBB, I)) {
|
||||||
Filled = true;
|
Filled = true;
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": found instruction for delay slot"
|
||||||
|
" in successor BB search.\n");
|
||||||
}
|
}
|
||||||
} else if (searchForward(MBB, I)) {
|
} else if (searchForward(MBB, I)) {
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": found instruction for delay slot"
|
||||||
|
" in forwards search.\n");
|
||||||
Filled = true;
|
Filled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,6 +668,8 @@ bool MipsDelaySlotFiller::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bundle the NOP to the instruction with the delay slot.
|
// Bundle the NOP to the instruction with the delay slot.
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": could not fill delay slot for ";
|
||||||
|
I->dump());
|
||||||
BuildMI(MBB, std::next(I), I->getDebugLoc(), TII->get(Mips::NOP));
|
BuildMI(MBB, std::next(I), I->getDebugLoc(), TII->get(Mips::NOP));
|
||||||
MIBundleBuilder(MBB, I, std::next(I, 2));
|
MIBundleBuilder(MBB, I, std::next(I, 2));
|
||||||
++FilledSlots;
|
++FilledSlots;
|
||||||
|
@ -679,13 +687,19 @@ bool MipsDelaySlotFiller::searchRange(MachineBasicBlock &MBB, IterTy Begin,
|
||||||
for (IterTy I = Begin; I != End;) {
|
for (IterTy I = Begin; I != End;) {
|
||||||
IterTy CurrI = I;
|
IterTy CurrI = I;
|
||||||
++I;
|
++I;
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": checking instruction: "; CurrI->dump());
|
||||||
// skip debug value
|
// skip debug value
|
||||||
if (CurrI->isDebugInstr())
|
if (CurrI->isDebugInstr()) {
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": ignoring debug instruction: ";
|
||||||
|
CurrI->dump());
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (terminateSearch(*CurrI))
|
if (terminateSearch(*CurrI)) {
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": should terminate search: ";
|
||||||
|
CurrI->dump());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
assert((!CurrI->isCall() && !CurrI->isReturn() && !CurrI->isBranch()) &&
|
assert((!CurrI->isCall() && !CurrI->isReturn() && !CurrI->isBranch()) &&
|
||||||
"Cannot put calls, returns or branches in delay slot.");
|
"Cannot put calls, returns or branches in delay slot.");
|
||||||
|
@ -731,6 +745,9 @@ bool MipsDelaySlotFiller::searchRange(MachineBasicBlock &MBB, IterTy Begin,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Filler = CurrI;
|
Filler = CurrI;
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": found instruction for delay slot: ";
|
||||||
|
CurrI->dump());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,8 +768,11 @@ bool MipsDelaySlotFiller::searchBackward(MachineBasicBlock &MBB,
|
||||||
|
|
||||||
MachineBasicBlock::iterator SlotI = Slot;
|
MachineBasicBlock::iterator SlotI = Slot;
|
||||||
if (!searchRange(MBB, ++SlotI.getReverse(), MBB.rend(), RegDU, MemDU, Slot,
|
if (!searchRange(MBB, ++SlotI.getReverse(), MBB.rend(), RegDU, MemDU, Slot,
|
||||||
Filler))
|
Filler)) {
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": could not find instruction for delay "
|
||||||
|
"slot using backwards search.\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MBB.splice(std::next(SlotI), &MBB, Filler.getReverse());
|
MBB.splice(std::next(SlotI), &MBB, Filler.getReverse());
|
||||||
MIBundleBuilder(MBB, SlotI, std::next(SlotI, 2));
|
MIBundleBuilder(MBB, SlotI, std::next(SlotI, 2));
|
||||||
|
@ -772,8 +792,11 @@ bool MipsDelaySlotFiller::searchForward(MachineBasicBlock &MBB,
|
||||||
|
|
||||||
RegDU.setCallerSaved(*Slot);
|
RegDU.setCallerSaved(*Slot);
|
||||||
|
|
||||||
if (!searchRange(MBB, std::next(Slot), MBB.end(), RegDU, NM, Slot, Filler))
|
if (!searchRange(MBB, std::next(Slot), MBB.end(), RegDU, NM, Slot, Filler)) {
|
||||||
|
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": could not find instruction for delay "
|
||||||
|
"slot using forwards search.\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MBB.splice(std::next(Slot), &MBB, Filler);
|
MBB.splice(std::next(Slot), &MBB, Filler);
|
||||||
MIBundleBuilder(MBB, Slot, std::next(Slot, 2));
|
MIBundleBuilder(MBB, Slot, std::next(Slot, 2));
|
||||||
|
|
Loading…
Reference in New Issue