[PATCH] Teach DeadArgElimination not to eliminate return values of functions with 'returned' arguments

Stephen Lin swlin at post.harvard.edu
Thu Jun 20 15:36:54 PDT 2013


Hi,

This patch makes the DeadArgElimination IPO pass treat any return
value of any function with a 'returned' argument as live even if there
are no uses. This is meant to allow the clang patch committed as
revision r184205 (and subsequent minor fixes) to be recommitted after
being reverted in revision r184205 due to broken builds on ARM when
compiling with LTO.

The 'returned' attribute is relatively new and indicates, as an
optimization hint to the caller, that a function always returns the
value of an argument as its return value. In the intended use cases,
it is almost always better to leave the return value on the function
than to take it off, because it's essentially free. (Specifically, for
a 'this'-returning constructor/destructor in the ARM C++ ABI using the
ARM calling convention, the 'this'-argument and the return value as in
the same register so the caller and callee basically can both leave it
untouched unless there is significant register pressure.)

The patch includes comments describing the rationale for retaining the
return value in these cases and also includes a note that this should
be reinvestigated if 'returned' is applied more liberally in the
future.

Any and all feedback is highly appreciated.

Stephen

<rdar://problem/14209661>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: returned-lto-fix.patch
Type: application/octet-stream
Size: 5642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130620/47bfad0f/attachment.obj>


More information about the llvm-commits mailing list