From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 7A18B3851153 for ; Mon, 12 Sep 2022 14:48:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A18B3851153 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3854E22C3B; Mon, 12 Sep 2022 14:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1662994099; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E+yn3I9pLzDy2Q8KpceLzRmblotLZvkyb3AoinwaldU=; b=oRXIkLp21Y1XUEbBeNRu4Sb2zCyTkcJ9fJQDAXoMifvOunnSyJQ+zMq1OSTZ78cuOVBa3m XZDsjMMu8C4132RzsPBlEmV7ZmZ/1NePXOjKf/rmS2d614KoIE0KFXhZzNTMGuDOsEv/iu QOLoJXIuWwoXxtWyeisfP1IKpG/+mmo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1662994099; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E+yn3I9pLzDy2Q8KpceLzRmblotLZvkyb3AoinwaldU=; b=nGd+pNXcfrMw2Yqs3SbUmYVbRrmyuVJG3O3RGvh2CEWERQ3ItXbis/Z9SeamKHqqochz6C xsXC7NZw4xir6kAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2CECC139C8; Mon, 12 Sep 2022 14:48:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id udDxCrNGH2NKUAAAMHmgww (envelope-from ); Mon, 12 Sep 2022 14:48:19 +0000 From: Martin Jambor To: Fredrik Hederstierna Cc: "gcc@gcc.gnu.org" Subject: Re: Question unused function parameter data garbage collection In-Reply-To: References: User-Agent: Notmuch/0.35 (https://notmuchmail.org) Emacs/28.1 (x86_64-suse-linux-gnu) Date: Mon, 12 Sep 2022 16:48:18 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, On Mon, Sep 12 2022, Richard Biener via Gcc wrote: > 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. > or, if possible, make the function static. Martin