public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Fredrik Hederstierna <fredrik.hederstierna@verisure.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Question unused function parameter data garbage collection
Date: Mon, 12 Sep 2022 14:30:34 +0200	[thread overview]
Message-ID: <CAFiYyc1-trGeSueiwpV33iXWTiL_QCAjYp-13N9Ro7Fhs58_kQ@mail.gmail.com> (raw)
In-Reply-To: <HE1PR1001MB11801D262FEE4C78ACE6F8BDEF449@HE1PR1001MB1180.EURPRD10.PROD.OUTLOOK.COM>

On Mon, Sep 12, 2022 at 1:23 PM Fredrik Hederstierna via Gcc
<gcc@gcc.gnu.org> wrote:
>
> Hi,
>
> We have a function that does not used an in-parameter, simplified example:
>
> void test_unused_string_param_gc(const char* unused)
> {
>    // empty
> }
>
> Though when we have calls to this function, the arguments are still put in the memory, causing unnecessary flash memory usage for 'dead parameters'.
>
> Example if having a call (from another file) as
>
>       test_unused_string_param_gc("This string is not garbage-collected?");
>
> Then this string will still be added to our finally build binary?
>
> We compile with -Os, and have tried different flags to try get rid of this dead parameter data,
> do anyone know if this is the expected behavior and why? Or if we are missing any optimization flags, like LTO etc?

Without LTO there is no way the unused parameter can be elided on the
caller side so yes, try enabling LTO.

Richard.

> Best Regards,
> Fredrik
>

  reply	other threads:[~2022-09-12 12:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 11:21 Fredrik Hederstierna
2022-09-12 12:30 ` Richard Biener [this message]
2022-09-12 14:48   ` Martin Jambor

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=CAFiYyc1-trGeSueiwpV33iXWTiL_QCAjYp-13N9Ro7Fhs58_kQ@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=fredrik.hederstierna@verisure.com \
    --cc=gcc@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).