Prevent FENTRY_CALL reordering
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 8 Dec 2020 21:04:00 +0000 (22:04 +0100)
committerIlya Leoshkevich <iii@linux.ibm.com>
Tue, 8 Dec 2020 23:59:01 +0000 (00:59 +0100)
commitd58f112ce03877f73200591cd3c9b38e41e46afe
treebfd8e09a8bc72a4c6de64aead55b8d709549407e
parent5171b7b40e9813e3fbfaf1e1e3372895c9ff6081
Prevent FENTRY_CALL reordering

FEntryInserter prepends FENTRY_CALL to the first basic block. In case
there are other instructions, PostRA Machine Instruction Scheduler can
move FENTRY_CALL call around. This actually occurs on SystemZ (see the
testcase). This is bad for the following reasons:

* FENTRY_CALL clobbers registers.
* Linux Kernel depends on whatever FENTRY_CALL expands to to be the very
  first instruction in the function.

Fix by adding isCall attribute to FENTRY_CALL, which prevents reordering
by making it a scheduling boundary for PostRA Machine Instruction
Scheduler.

Reviewed By: niravd

Differential Revision: https://reviews.llvm.org/D91218
llvm/include/llvm/Target/Target.td
llvm/lib/CodeGen/MachineInstr.cpp
llvm/test/CodeGen/SystemZ/fentry-debug-info.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fentry-no-reorder.ll [new file with mode: 0644]