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)
commit86aef0a4f093700420c76f313e5668c39db110aa
tree8a242bf9b03cac7d41ffe6a208f70dc6f7815905
parente623702c22e7cee4e02332b245a417a88ae6ffff
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167396 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCCallingConv.td
lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/coalesce-ext.ll
test/CodeGen/PowerPC/ppc64-abi-extend.ll [new file with mode: 0644]