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 >