https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113596

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #9)
> Created attachment 57215 [details]
> gcc14-pr113596.patch
> 
> Untested patch to do that.
> The disadvantage of doing that is that it may penalize inline calls which
> just use VLAs, because calls_alloca covers even those functions.  For simple:
> static inline __attribute__((always_inline)) void
> foo (int n)
> {
>   char p[n];
>   bar (p, n);
> }
> the fab1 pass actually removes redundant pair of stack_save/stack_restore,
> but
> bet if it would be something like { call (); { char p[n]; bar (p, n); } call
> (); } then it wouldn't.
> Anyway, this isn't a regression, so I think it is stage1 material for GCC 15.

Most definitely.  We can make ->calls_alloca more precise though of course
we usually also do not want to inline functions with VLAs.  IIRC a VLA
forces a frame pointer for the caller then.

Reply via email to