[PATCH] D19051: [mips] Fix forbidden slot hazard handling
Simon Dardis via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 03:18:08 PDT 2016
sdardis created this revision.
sdardis added a subscriber: llvm-commits.
sdardis set the repository for this revision to rL LLVM.
Herald added subscribers: sdardis, dsanders.
MipsHazardSchedule has to determine what the next physical machine instruction
is to decide whether to insert a nop. In case where a branch with a forbidden
slot appears at the end of a basic block, first *real* instruction of the next
physical basic block was determined using getFirstNonDebugInstr().
Unfortunately this only considers DBG_VALUEs and not other transient opcodes
such as EHLABEL. As EHLABEL passes the SafeInForbiddenSlot predicate and the
instruction after the EHLABEL can be a CTI, we observed test failures in the
LNT testsuite.
Repository:
rL LLVM
http://reviews.llvm.org/D19051
Files:
lib/Target/Mips/MipsHazardSchedule.cpp
Index: lib/Target/Mips/MipsHazardSchedule.cpp
===================================================================
--- lib/Target/Mips/MipsHazardSchedule.cpp
+++ lib/Target/Mips/MipsHazardSchedule.cpp
@@ -92,6 +92,15 @@
return new MipsHazardSchedule();
}
+// Find the next real instruction from the current position.
+static Iter getNextMachineInstr(Iter Position) {
+ Iter I = Position, E = Position->getParent()->end();
+ while (I != E && I->isTransient())
+ I++;
+
+ return I;
+}
+
bool MipsHazardSchedule::runOnMachineFunction(MachineFunction &MF) {
const MipsSubtarget *STI =
@@ -114,14 +123,14 @@
bool InsertNop = false;
// Next instruction in the basic block.
if (std::next(I) != FI->end() &&
- !TII->SafeInForbiddenSlot(*std::next(I))) {
+ !TII->SafeInForbiddenSlot(*getNextMachineInstr(std::next(I)))) {
InsertNop = true;
} else {
// Next instruction in the physical successor basic block.
for (auto *Succ : FI->successors()) {
if (FI->isLayoutSuccessor(Succ) &&
- Succ->getFirstNonDebugInstr() != Succ->end() &&
- !TII->SafeInForbiddenSlot(*Succ->getFirstNonDebugInstr())) {
+ getNextMachineInstr(Succ->begin()) != Succ->end() &&
+ !TII->SafeInForbiddenSlot(*getNextMachineInstr(Succ->begin()))) {
InsertNop = true;
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19051.53527.patch
Type: text/x-patch
Size: 1425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160413/a97ad39a/attachment.bin>
More information about the llvm-commits
mailing list