[X86] Don't match x87 register inline asm constraints unless the VT is floating point...
authorCraig Topper <craig.topper@intel.com>
Thu, 17 Sep 2020 17:33:34 +0000 (10:33 -0700)
committerCraig Topper <craig.topper@intel.com>
Thu, 17 Sep 2020 18:26:50 +0000 (11:26 -0700)
commit3783d3bc7b3dd966ac3b9436b73f16f855d12ff2
tree3929b6f0155f0c1c1ce03528d474173d3051871f
parent0602e8f77f8662c85155b8cf02937a2e71c01e12
[X86] Don't match x87 register inline asm constraints unless the VT is floating point or its a clobber

The register class picked will be the RFP80 register class which has a f80 VT. The code in SelectionDAGBuilder that generates copies around inline assembly doesn't know how to handle an integer and floating point type of different bit widths.

The test case is derived from this https://godbolt.org/z/sEa659 which gcc accepts but clang crashes on. This patch just gives a more graceful error. I'm not sure if the single element struct case is special in gcc. Adding another field to the struct makes gcc reject it. If we want to support this correctly I think we need a change in the frontend to give us the true element type. Right now the frontend just realizes the constraint can take a memory argument so creates an integer type of the same size and bitcasts.

Differential Revision: https://reviews.llvm.org/D87485
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/asm-reject-x87-int.ll [new file with mode: 0644]