[SystemZ] Support large LLVM IR struct return values
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 13 Aug 2015 13:37:06 +0000 (13:37 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 13 Aug 2015 13:37:06 +0000 (13:37 +0000)
commit69585fd51be3cf8ebeec649f1d3ba33e47759a68
treeb705a3ce301f0b9f7c055adf5819a0f3654f21d8
parente65e298541646322234f94dab3387b165e65f704
[SystemZ] Support large LLVM IR struct return values

Recent mesa/llvmpipe crashes on SystemZ due to a failed assertion when
attempting to compile a routine with a return type of
  { <4 x float>, <4 x float>, <4 x float>, <4 x float> }
on a system without vector instruction support.

This is because after legalizing the vector type, we get a return value
consisting of 16 floats, which cannot all be returned in registers.

Usually, what should happen in this case is that the target's CanLowerReturn
routine rejects the return type, in which case SelectionDAG falls back to
implementing a structure return in memory via implicit reference.

However, the SystemZ target never actually implemented any CanLowerReturn
routine, and thus would accept any struct return type.

This patch fixes the crash by implementing CanLowerReturn.  As a side effect,
this also handles fp128 return values, fixing a todo that was noted in
SystemZCallingConv.td.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244889 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/SystemZ/SystemZCallingConv.td
lib/Target/SystemZ/SystemZISelLowering.cpp
lib/Target/SystemZ/SystemZISelLowering.h
test/CodeGen/SystemZ/args-04.ll
test/CodeGen/SystemZ/args-07.ll [new file with mode: 0644]
test/CodeGen/SystemZ/args-08.ll [new file with mode: 0644]
test/CodeGen/SystemZ/vec-args-06.ll [new file with mode: 0644]
test/CodeGen/SystemZ/vec-args-07.ll [new file with mode: 0644]