From patchwork Thu Jan 6 08:38:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1575971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=JO9tZR51; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV0CB4NJqz9sSs for ; Thu, 6 Jan 2022 19:39:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22ADC3858019 for ; Thu, 6 Jan 2022 08:39:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22ADC3858019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641458370; bh=074axPT+I0DndouuPBtvnp5WL7Wr4JVYWyB/JfyBGMc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=JO9tZR51YLpGOpl0AKfZNneO79SBJiOKHqqcg9KcfMDwZ2CGGckvfigHAYdEx/Iyg yn3zTu4uZTLF7KAZFL+73ro/ro0Ypy2yEXiC76vA55bulaukyMKeu4a4AZ/pk+L1aN NbGikuWIipZ3QhL29+Cl/TrsW0KX1ROEDAGOAhtE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 560F83858D39 for ; Thu, 6 Jan 2022 08:38:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 560F83858D39 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-bwWLXDKVPKWX2BF3chJRgA-1; Thu, 06 Jan 2022 03:38:45 -0500 X-MC-Unique: bwWLXDKVPKWX2BF3chJRgA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EDF3C1017965; Thu, 6 Jan 2022 08:38:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9051A60C25; Thu, 6 Jan 2022 08:38:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 2068cf9k128017 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 6 Jan 2022 09:38:42 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 2068cfkq128016; Thu, 6 Jan 2022 09:38:41 +0100 Date: Thu, 6 Jan 2022 09:38:40 +0100 To: Richard Biener , Jeff Law Subject: [PATCH] expr: Workaround profiledbootstrap uninit false positive [PR103899] Message-ID: <20220106083840.GV2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! The threader changes resulted in a false positive warning during profiledbootstrap: In file included from ../../gcc/expr.c:26: ../../gcc/tree.h: In function ‘rtx_def* expand_expr_real_1(tree, rtx, machine_mode, expand_modifier, rtx_def**, bool)’: ../../gcc/tree.h:244:56: error: ‘context’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 244 | #define TREE_CODE(NODE) ((enum tree_code) (NODE)->base.code) | ^~~~ ../../gcc/expr.c:10343:8: note: ‘context’ was declared here 10343 | tree context; | ^~~~~~~ While it will be nice to improve the uninit pass to handle it if possible (I do not want to close the PR until that is done), doing profiledbootstrap is a common thing to do, so a workaround is handy, especially as in this case when the workaround seems to be the right thing to do, as it moves a variable declaration to the only place where it is set and used and avoids the weird and for uninit asking tree context; ... if (exp) context = ...; gcc_assert (!exp || use (context) || use_some_more (context)); Bootstrapped/regtested on x86_64-linux and i686-linux with normal bootstrap and on aarch64-linux and powerpc64le-linux with profiledbootstrap, ok for trunk? 2022-01-06 Jakub Jelinek PR tree-optimization/103899 * expr.c (expand_expr_real_1): Add a workaround for bogus uninit warning by moving context variable to the only spot where it is used and moving gcc_assert into if body. Jakub --- gcc/expr.c.jj 2022-01-03 10:40:41.203164211 +0100 +++ gcc/expr.c 2022-01-05 14:47:47.684660031 +0100 @@ -10340,7 +10340,6 @@ expand_expr_real_1 (tree exp, rtx target enum tree_code code = TREE_CODE (exp); rtx subtarget, original_target; int ignore; - tree context; bool reduce_bit_field; location_t loc = EXPR_LOCATION (exp); struct separate_ops ops; @@ -10579,14 +10578,16 @@ expand_expr_real_1 (tree exp, rtx target /* Variables inherited from containing functions should have been lowered by this point. */ if (exp) - context = decl_function_context (exp); - gcc_assert (!exp - || SCOPE_FILE_SCOPE_P (context) - || context == current_function_decl - || TREE_STATIC (exp) - || DECL_EXTERNAL (exp) - /* ??? C++ creates functions that are not TREE_STATIC. */ - || TREE_CODE (exp) == FUNCTION_DECL); + { + tree context = decl_function_context (exp); + gcc_assert (SCOPE_FILE_SCOPE_P (context) + || context == current_function_decl + || TREE_STATIC (exp) + || DECL_EXTERNAL (exp) + /* ??? C++ creates functions that are not + TREE_STATIC. */ + || TREE_CODE (exp) == FUNCTION_DECL); + } /* This is the case of an array whose size is to be determined from its initializer, while the initializer is still being parsed.