From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85464 invoked by alias); 3 Aug 2015 19:35:19 -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 85365 invoked by uid 89); 3 Aug 2015 19:35:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 03 Aug 2015 19:35:16 +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 (Postfix) with ESMTPS id E2008A4A01; Mon, 3 Aug 2015 19:35:13 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-21.phx2.redhat.com [10.3.113.21]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t73JZ8hT014673; Mon, 3 Aug 2015 15:35:09 -0400 Subject: Re: Fix PR43404, PR48470, PR64744 ICE on naked functions To: Alexander Basov References: <556E1DA5.4070701@redhat.com> <556F6079.7080209@gmail.com> <558C4CDB.9030609@redhat.com> Cc: gcc-patches@gcc.gnu.org From: Jeff Law Message-ID: <55BFC26B.1040707@redhat.com> Date: Mon, 03 Aug 2015 19:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00117.txt.bz2 On 06/29/2015 07:32 AM, Alexander Basov wrote: > I've updated patch with attributes lookup. > is it OK? > > -- Alexander 2015-06-26 9:33 GMT+03:00 Alexander Basov : >> >2015-06-25 21:47 GMT+03:00 Jeff Law: >>> >>On 06/03/2015 02:15 PM, Alexander Basov wrote: >>>> >>> >>>> >>>Hello Jeff, >>>> >>>please find updated patch attached >>>> >>> >>>>>> >>>>>diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c >>>>>> >>>>>index b190f91..c6db8a9 100644 >>>>>> >>>>>--- a/gcc/cfgexpand.c >>>>>> >>>>>+++ b/gcc/cfgexpand.c >>>>>> >>>>>@@ -1382,7 +1382,15 @@ expand_one_var (tree var, bool toplevel, bool >>>>>> >>>>>really_expand) >>>>>> >>>>> else >>>>>> >>>>> { >>>>>> >>>>> if (really_expand) >>>>>> >>>>>- expand_one_stack_var (origvar); >>>>>> >>>>>+ { >>>>>> >>>>>+ if (!targetm.calls.allocate_stack_slots_for_args ()) >>>>>> >>>>>+ error ("cannot allocate stack for variable %q+D, naked >>>>>> >>>>>function.", >>>>>> >>>>>+ var); >>>>>> >>>>>+ >>>>>> >>>>>+ expand_one_stack_var (origvar); >>>>>> >>>>>+ } >>>>> >>>> >>>>> >>>>So how do you know ORIGVAR is an argument here before issuing the >>>>> >>>>error? ie, shouldn't you verify that the underlying object is a >>>>> >>>>PARM_DECL? If there's some way we already know we're dealing with a >>>>> >>>>PARM_DECL, then just say so. >>>> >>> >>>> >>>In case of naked function stack should not be used not only for function >>>> >>>args, but also for any local variables. >>>> >>>So, i think we don't need to check if underlying object is a PARM_DECL. >>> >> >>> >>Then that would indicate that we're using the wrong test >>> >>(allocate_stack_slot_for_args). That hook is for whether or not arguments >>> >>should have stack slots allocated. Yet you're issuing an error for more >>> >>than just PARM_DECLs. >>> >> >>> >>Shouldn't you instead be checking if the current function is a naked >>> >>function or not by checking the attributes of the current function? >>> >> >>> >>Jeff >> > >> >What allocate_stack_slots_for_args does, it only checks if current >> >function is naked or not. >> >May be it will be better to remove allocate_stack_slots_for_args and >> >replace if with explicit checking of naked attribute? >> > >> >-- >> >Alexander > > pr64744.patch > > > commit 3a72dac72beb713ab6a566728b77c4da6d297755 > Author: Alexander Basov > Date: Tue Mar 10 14:15:24 2015 +0300 > > PR middle-end/64744 > PR middle-end/48470 > PR middle-end/43404 > > * gcc/cfgexpand.c (expand_one_var): Add check if stack is going to > be used in naked function. > * gcc/expr.c (expand_expr_addr_expr_1): Remove exscess checking > whether expression should not reside in MEM. > * gcc/function.c (use_register_for_decl): Do not use registers for > non-register things (volatile, float, BLKMode) in naked functions. > > * gcc/testsuite/gcc.target/arm/pr43404.c : New testcase. > * gcc/testsuite/gcc.target/arm/pr48470.c : New testcase. > * gcc/testsuite/gcc.target/arm/pr64744-1.c : New testcase. > * gcc/testsuite/gcc.target/arm/pr64744-2.c : New testcase. Sorry for the long delay. I've fixed up minor nits in the ChangeLog and committed your fixes. Thanks, jeff