[MachinePipeliner] Add a way to unit-test the schedule emitter
authorJames Molloy <jmolloy@google.com>
Tue, 3 Sep 2019 08:20:31 +0000 (08:20 +0000)
committerJames Molloy <jmolloy@google.com>
Tue, 3 Sep 2019 08:20:31 +0000 (08:20 +0000)
commit935499579c2d58e64d597aa19f6bc8ea31e88f04
tree1da343ddf3ad5ecca94b856b18b701ce1925a794
parent8b2df85d023e6213543d0761eafa98fe914fdc0a
[MachinePipeliner] Add a way to unit-test the schedule emitter

Emitting a schedule is really hard. There are lots of corner cases to take care of; in fact, of the 60+ SWP-specific testcases in the Hexagon backend most of those are testing codegen rather than the schedule creation itself.

One issue is that to test an emission corner case we must craft an input such that the generated schedule uses that corner case; sometimes this is very hard and convolutes testcases. Other times it is impossible but we want to test it anyway.

This patch adds a simple test pass that will consume a module containing a loop and generate pipelined code from it. We use post-instr-symbols as a way to annotate instructions with the stage and cycle that we want to schedule them at.

We also provide a flag that causes the MachinePipeliner to generate these annotations instead of actually emitting code; this allows us to generate an input testcase with:

  llc < %s -stop-after=pipeliner -pipeliner-annotate-for-testing -o test.mir

And run the emission in isolation with:

  llc < test.mir -run-pass=modulo-schedule-test

llvm-svn: 370705
llvm/include/llvm/CodeGen/ModuloSchedule.h
llvm/include/llvm/InitializePasses.h
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/MachinePipeliner.cpp
llvm/lib/CodeGen/ModuloSchedule.cpp
llvm/test/CodeGen/Hexagon/pipeliner/swp-phi-start.mir [new file with mode: 0644]