From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32038 invoked by alias); 7 Jan 2014 13:27:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 32028 invoked by uid 89); 7 Jan 2014 13:27:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Jan 2014 13:27:08 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s07DR6aG015351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Jan 2014 08:27:06 -0500 Received: from oldenburg.str.redhat.com (oldenburg.str.redhat.com [10.33.200.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s07DR4S4015566 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 7 Jan 2014 08:27:05 -0500 Message-ID: <52CC00A8.7070203@redhat.com> Date: Tue, 07 Jan 2014 13:27:00 -0000 From: Florian Weimer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Jakub Jelinek CC: GCC Patches , shenhan@google.com Subject: Re: Extend -fstack-protector-strong to cover calls with return slot References: <52C6B807.1070203@redhat.com> <20140103185715.GO892@tucnak.redhat.com> <52C72F05.2060901@redhat.com> <52CBF834.3040004@redhat.com> <20140107130748.GP892@tucnak.redhat.com> In-Reply-To: <20140107130748.GP892@tucnak.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg00263.txt.bz2 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