public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
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 16:48:18 +0200	[thread overview]
Message-ID: <ri6czc0ir7x.fsf@suse.cz> (raw)
In-Reply-To: <CAFiYyc1-trGeSueiwpV33iXWTiL_QCAjYp-13N9Ro7Fhs58_kQ@mail.gmail.com>

Hi,

On Mon, Sep 12 2022, Richard Biener via Gcc wrote:
> 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.
>

or, if possible, make the function static.

Martin


      reply	other threads:[~2022-09-12 14:48 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
2022-09-12 14:48   ` Martin Jambor [this message]

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=ri6czc0ir7x.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --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).