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. So, you'd stack protect something only if not -O0 or -Og, that is just wrong, and only if it was suitable for NRV. You really want to protect all functions that call something that is returned by hidden reference. Jakub