[X86] Add ST0 as an implicit def/use of x87 load/store instructions during FP stackif...
authorCraig Topper <craig.topper@intel.com>
Mon, 4 Feb 2019 18:43:55 +0000 (18:43 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 4 Feb 2019 18:43:55 +0000 (18:43 +0000)
commit8ea72a82012481d34fd6e0e00c14dbb94ef9ec94
tree022b73b7b5ce0228d9008be35db477fc25e683a1
parent072382867573808d1cd5757799adfcdc697537c3
[X86] Add ST0 as an implicit def/use of x87 load/store instructions during FP stackifying.

These instructions implicitly operate on ST0, but we don't currently add that information to the MachineInstr. We also don't add it the tablegen definitions either.

For the most part this doesn't cause any problems because the stackifying occurs after register allocation. All the instructions are marked as having side effects so the postRA scheduler won't reorder them amongst themselves.

But nothing stops inline assembly using X87 instructions from being reordered around other x87 instructions if that inline assembly wasn't marked volatile.

The two test cases I've identified so far in PR40539 involve loads and stores used to set up the inline assembly or capture the results of the inline assembly ending up in the wrong order.

This patch adds implicit ST0 uses/defs to the load/store instructions to prevent this from happening.

I plan to fix all of the FP instructions, but the binops are bit trickier to get right. So I've chosen fixing the known test cases as a good first step.

I think we also need to update the tablegen descriptions so MS inline assembly infers the right clobbers, but I haven't checked that yet.

Differential Revision: https://reviews.llvm.org/D57644

llvm-svn: 353070
llvm/lib/Target/X86/X86FloatingPoint.cpp
llvm/test/CodeGen/X86/pr40539.ll