This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix PR43404, PR48470, PR64744 ICE on naked functions
- From: Alexander Basov <coopht at gmail dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 26 Jun 2015 09:33:13 +0300
- Subject: Re: Fix PR43404, PR48470, PR64744 ICE on naked functions
- Authentication-results: sourceware.org; auth=none
- References: <CAHpy5QpiQdEKe6+ds3kUu+k-5L+59Vjbs5AJdR_VZZwptutp6A at mail dot gmail dot com> <556E1DA5 dot 4070701 at redhat dot com> <556F6079 dot 7080209 at gmail dot com> <558C4CDB dot 9030609 at redhat dot com>
2015-06-25 21:47 GMT+03:00 Jeff Law <law@redhat.com>:
> 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