[patch] Fix PR middle-end/65958

Richard Biener richard.guenther@gmail.com
Wed Nov 18 10:25:00 GMT 2015


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



More information about the Gcc-patches mailing list