[llvm-commits] [PATCH] Respect sign-/zeroext attributes on i32 return values on ppc64

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Mon Nov 5 10:17:56 PST 2012


Hello,

on PowerPC64, integer return values (as well as arguments) are supposed to
be extended to a full register.   This is modeled in the LLVM IR by marking
the return value (or argument) with a signext or zeroext attribute.
(Actually, this is not in fact currently done by clang, but I've proposed a
patch to do that on cfe-commits.)

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

The 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.  (Note that for arguments, those tests would have already passed
without this patch.)

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, my patch now
adds an extra "add" to ensure we have an appropriate use of the i32
value ...

OK to commit?

Bye,
Ulrich

(See attached file: diff-llvm-ppc64-extendret)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-llvm-ppc64-extendret
Type: application/octet-stream
Size: 6573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121105/4ce4a230/attachment.obj>


More information about the llvm-commits mailing list