This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]