[patch] Fix PR middle-end/65958
Eric Botcazou
ebotcazou@adacore.com
Wed Nov 18 10:07:00 GMT 2015
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?
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vla-24.c
Type: text/x-csrc
Size: 378 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20151118/b90d7065/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr65958-3.diff
Type: text/x-patch
Size: 3122 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20151118/b90d7065/attachment-0001.bin>
More information about the Gcc-patches
mailing list