From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 7755F3858404 for ; Fri, 10 Sep 2021 08:19:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7755F3858404 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 729FF22419; Fri, 10 Sep 2021 08:19:40 +0000 (UTC) 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 56BFA13D1D; Fri, 10 Sep 2021 08:19:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KaDfExwVO2HVSgAAMHmgww (envelope-from ); Fri, 10 Sep 2021 08:19:40 +0000 Date: Fri, 10 Sep 2021 10:19:40 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: qing.zhao@oracle.com, keescook@chromium.org Subject: [PATCH] middle-end/102269 - avoid auto-init of empty types Message-ID: <623prp9r-16q8-8s61-r140-7714p89p315@fhfr.qr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Sep 2021 08:19:42 -0000 This avoids initializing empty types for which we'll eventually leave a .DEFERRED_INIT call without a LHS. Bootstrap & regtest running on x86_64-unknown-linux-gnu. 2021-09-10 Richard Biener PR middle-end/102269 * gimplify.c (is_var_need_auto_init): Empty types do not need initialization. * gcc.dg/pr102269.c: New testcase. --- gcc/gimplify.c | 3 ++- gcc/testsuite/gcc.dg/pr102269.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr102269.c diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 3314f76cf3f..8820f873993 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1826,7 +1826,8 @@ is_var_need_auto_init (tree decl) { if (auto_var_p (decl) && (flag_auto_var_init > AUTO_INIT_UNINITIALIZED) - && (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl)))) + && (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl))) + && !is_empty_type (TREE_TYPE (decl))) return true; return false; } diff --git a/gcc/testsuite/gcc.dg/pr102269.c b/gcc/testsuite/gcc.dg/pr102269.c new file mode 100644 index 00000000000..9d41b8fd7c7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr102269.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-ftrivial-auto-var-init=zero" } */ + +void fn() { int a[0]; } -- 2.31.1