On 01/07/2014 02:07 PM, Jakub Jelinek wrote:
On Tue, Jan 07, 2014 at 01:51:00PM +0100, Florian Weimer wrote:
+static bool
+stack_protect_return_slot_p ()
+{
+ basic_block bb;
+
+ FOR_ALL_BB_FN (bb, cfun)
+ for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
+ !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ if (is_gimple_call (stmt) && gimple_call_return_slot_opt_p (stmt))
I have to repeat, this is not the right test, it really is just an
optimization hint, nothing else. Just look where it is set (unless it is
C++ where some NRV is performed in the FE as mandated by the languages)
- in pass_return_slot, which is an optimization pass, not run with -O0 or
-Og at all.
I don't understand. The corresponding tree flag is set by
gimplify_modify_expr_rhs, in the CALL_EXPR case:
if (use_target)
{
CALL_EXPR_RETURN_SLOT_OPT (*from_p) = 1;
mark_addressable (*to_p);
}
Isn't this an integral part of the gimplifier which also runs at -O0? I
certainly see the flag in the generated gimple at -O0, with the amended
C test case:
foo11 ()
{
int D.2037;
struct B D.2038;
D.2038 = global3 (); [return slot optimization]
D.2037 = D.2038.a1;
return D.2037;
}
As I said, I think the function gimple_call_return_slot_opt_p is
misnamed because it's not actually an optimization.
--
Florian Weimer / Red Hat Product Security Team