On PowerPC64, integer return values (as well as arguments) are supposed
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 5 Nov 2012 19:39:45 +0000 (19:39 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 5 Nov 2012 19:39:45 +0000 (19:39 +0000)
commit339d0597d37c4ec256862007dd1d3079448e7b51
treeb5f9a73f2beca9da8e835d5b7afd386ad7115b19
parent7411623fd88035797ef55d53bd0d95b85c4e9e40
On PowerPC64, integer return values (as well as arguments) are supposed
to be extended to a full register.   This is modeled in the IR by marking
the return value (or argument) with a signext or zeroext attribute.

However, while these attributes are respected for function arguments,
they are currently ignored for function return values by the PowerPC
back-end.  This patch updates PPCCallingConv.td to ask for the promotion
to i64, and fixes LowerReturn and LowerCallResult to implement it.

The new test case verifies that both arguments and return values are
properly extended when passing them; and also that the optimizers
understand incoming argument and return values are in fact guaranteed
by the ABI to be extended.

The patch caused a spurious breakage in CodeGen/PowerPC/coalesce-ext.ll,
since the test case used a "ret" instruction to create a use of an i32
value at the end of the function (to set up data flow as required for
what the test is intended to test).  Since there's now an implicit
promotion to i64, that data flow no longer works as expected.  To fix
this, this patch now adds an extra "add" to ensure we have an appropriate
use of the i32 value.

llvm-svn: 167396
llvm/lib/Target/PowerPC/PPCCallingConv.td
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/coalesce-ext.ll
llvm/test/CodeGen/PowerPC/ppc64-abi-extend.ll [new file with mode: 0644]