This is an archive of the discontinued LLVM Phabricator instance.

[mips] Fix forbidden slot hazard handling
ClosedPublic

Authored by sdardis on Apr 13 2016, 3:18 AM.

Details

Reviewers
dsanders
Summary

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.

Diff Detail

Event Timeline

sdardis updated this revision to Diff 53527.Apr 13 2016, 3:18 AM
sdardis retitled this revision from to [mips] Fix forbidden slot hazard handling.
sdardis updated this object.
sdardis set the repository for this revision to rL LLVM.
sdardis added a subscriber: llvm-commits.

Ping. I have not been able to add a test case to cover this, as the MIR parser doesn't yet cover parsing EH_LABELs. The LLVM test suite covers the change:

MultiSource/Benchmarks/Bullet/bullet
MultiSource/Benchmarks/PAQ8p/paq8p
SingleSource/Benchmarks/Misc-C++-EH/spirit
SingleSource/Benchmarks/Misc-C++/bigfib
SingleSource/Benchmarks/Shootout-C++/lists1

Those tests fail without this change, as EH_LABEL is non-debug instruction causing a sequence of a compact branch followed by a jal.

dsanders accepted this revision.Apr 29 2016, 4:05 AM
dsanders added a reviewer: dsanders.

LGTM with a couple nits

lib/Target/Mips/MipsHazardSchedule.cpp
98–99

This loop seems equivalent to:

return std::find_if(I, E, [](const auto &Insn) { return !Insn->isTransient(); })

Also, we should assert that we don't return E.

This revision is now accepted and ready to land.Apr 29 2016, 4:05 AM
sdardis closed this revision.Apr 29 2016, 9:10 AM
sdardis marked an inline comment as done.

Committed as rL268052.