This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to strip unnecessary TARGET_EXPRs for c++/27371
- From: Jason Merrill <jason at redhat dot com>
- To: "gcc-patches >> GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 06 Sep 2006 21:10:16 -0400
- Subject: PATCH to strip unnecessary TARGET_EXPRs for c++/27371
The C++ front end automatically wraps all calls to functions that return
a class with a TARGET_EXPR in order to track the temporary object
returned from the function. This becomes a MODIFY_EXPR during
gimplification, and makes it difficult to see that the return value is
in fact never used.
This patch strips such TARGET_EXPRs in convert_to_void and fixes the
warning. The temporaries will now be allocated in expand_call or
declare_return_variable (which needed some adjustment to handle
allocating a return slot in the case of DECL_BY_REFERENCE).
I hoped that shifting these unused temporaries to being allocated at RTL
conversion time through assign_temp would also help with 25505, but in
fact it doesn't have any effect; the assign_temp temporaries aren't
currently shared any better than gimple temporaries. But it should be
possible to improve that; there should be no reason for an assign_temp
temporary to live longer than a single gimple statement, anything that
needs to live longer should already be represented in the gimple.
Tested x86_64-pc-linux-gnu, applied to trunk.