This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix PR middle-end/65958
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 18 Nov 2015 11:25:05 +0100
- Subject: Re: [patch] Fix PR middle-end/65958
- Authentication-results: sourceware.org; auth=none
- References: <1750746 dot G8iFFmz9eE at polaris>
On Wed, Nov 18, 2015 at 11:06 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this is the underlying issue of PR middle-end/65958: the compiler generates
> wrong code when alloca is used in conjunction with a VLA since the latter
> causes the stack space allocated to the former to be wrongly reclaimed.
> So the proposed fix is not to reclaim any stack space in this case.
>
> Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 5.x branch?
Ok. I wonder if we document GCCs VLA implementation somewhere so we can add
a note on the interaction with alloca.
Thanks,
Richard.
>
> 2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
>
> PR middle-end/65958
> * gimplify.c (struct gimplify_ctx): Turn boolean fields into 1-bit
> fields, add keep_stack and reorder them.
> (gimplify_bind_expr): Save gimplify_ctxp->keep_stack on entry then
> set it to false. Do not insert a stack save/restore pair if it has
> been set to true by the gimplification of the statements.
> Restore it to the saved value on exit if it is still false.
> (gimplify_vla_decl): Do not set gimplify_ctxp->save_stack here.
> (gimplify_call_expr) <BUILT_IN_ALLOCA[_WITH_ALIGN]>: New case. Set
> either save_stack or keep_stack depending on CALL_ALLOCA_FOR_VAR_P.
>
>
> 2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
>
> * gcc.dg/vla-24.c: New test.
>
> --
> Eric Botcazou