From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 028073856DE6 for ; Mon, 12 Sep 2022 12:30:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 028073856DE6 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x634.google.com with SMTP id y3so19875883ejc.1 for ; Mon, 12 Sep 2022 05:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=jYlpbBDIIFXbCiqo0FJqzLHhw4LAsKxYRDMNfjayN8g=; b=YjadOXv8dfR6IOHwbl9dlikLkRdUMJ+5VX5lwKoP8nRLndngwGGfNPgECXMeRdLyyk KTunhKeA4T3EWjaPfhFQLEcGrLTAwQuVy+GOuji0hdVN+5SOnxKUNf+7fu6XWsyVikRx oAP9mYXNtSrAlOjvHfeS3Qx41nB6G83xTDYhVEZO0T/w7U/WkAbQdNGR1UKCXhZtqjOz A86MceO5MK5qlg7Phy7gluYg80IyZykO/44xFN33P4mHY76qK1nZCCbhEYvlTeJbxycb Z22zYyKAqRBsQ6DxZXEdZU8ZxKUlhblxynMPprFC4U5ZBUAcNBi6t8JCA1mw/kJ2MEbw UEOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=jYlpbBDIIFXbCiqo0FJqzLHhw4LAsKxYRDMNfjayN8g=; b=GA7p182EKZ5F0QCXCUpyKr6UJaoxvKH2KjfH3X/svh+CxhAIoDbdGCRazlHnqroGcF uhYJyBoQ+WBs6CJQAX05k27n9Y2A6gIKd90PNUbgauHSYzHkgfmFa7mtorU8nu/r5wOk rm8ER2j2t+s7PGnVQCh0t1zYjVj4jw2Z1zCoLXJMhZGJlLNz48b1xUvT5aDB9Cg5E7Nj ncB7jqkIfPbE1DmGkhmcSsRTdmRJq5uvFbt/V78IB5pDQSfMr2SRaFGla+QiObHWiKeO aBPdZOhaWwoPsv8NuMBLE0+SxFp3i0blDeejhqnYNP2BQpp4CkSesUambujLxA9X5AqR D22w== X-Gm-Message-State: ACgBeo0Q/apbcGJaYoyN/s0McN23IETYnnGMK85jG+AY8LdQK/boie7P yMiGpyUmCVPaDe9IeAJVjbinWAafwCguKkw7eBQ= X-Google-Smtp-Source: AA6agR6i9qDMv+4bKRQBgTvK0HGIQcGm7OpLpB+YAVwbnVrA6eEmhyA601cicinozYnYjhfjIGaPzyjo/a8Xo6OFx70= X-Received: by 2002:a17:907:3e12:b0:738:fd2f:df80 with SMTP id hp18-20020a1709073e1200b00738fd2fdf80mr19170798ejc.29.1662985846672; Mon, 12 Sep 2022 05:30:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Mon, 12 Sep 2022 14:30:34 +0200 Message-ID: Subject: Re: Question unused function parameter data garbage collection To: Fredrik Hederstierna Cc: "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Sep 12, 2022 at 1:23 PM Fredrik Hederstierna via Gcc 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 >