public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/113596] Stack memory leakage caused by inline alloca
Date: Thu, 25 Jan 2024 14:29:55 +0000	[thread overview]
Message-ID: <bug-113596-4-D64CD4YODK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113596-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2024-01-25 14:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25  9:31 [Bug c/113596] New: " sanpeqf at gmail dot com
2024-01-25  9:38 ` [Bug middle-end/113596] " pinskia at gcc dot gnu.org
2024-01-25  9:38 ` pinskia at gcc dot gnu.org
2024-01-25  9:40 ` pinskia at gcc dot gnu.org
2024-01-25  9:45 ` sanpeqf at gmail dot com
2024-01-25  9:48 ` sanpeqf at gmail dot com
2024-01-25  9:57 ` sanpeqf at gmail dot com
2024-01-25 10:06 ` rguenth at gcc dot gnu.org
2024-01-25 12:48 ` jakub at gcc dot gnu.org
2024-01-25 14:26 ` jakub at gcc dot gnu.org
2024-01-25 14:29 ` rguenth at gcc dot gnu.org [this message]
2024-01-25 14:34 ` jakub at gcc dot gnu.org
2024-05-03  7:45 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113596-4-D64CD4YODK@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).