From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1272 invoked by alias); 23 Jul 2019 16:20:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 959 invoked by uid 89); 23 Jul 2019 16:20:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=instrument X-HELO: mail-vs1-f66.google.com Received: from mail-vs1-f66.google.com (HELO mail-vs1-f66.google.com) (209.85.217.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Jul 2019 16:20:30 +0000 Received: by mail-vs1-f66.google.com with SMTP id y16so29169810vsc.3 for ; Tue, 23 Jul 2019 09:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=3Ep6pEwnc0KdsswdH35PJH1ZlwOoZ8f4MTi9vCjuu4U=; b=A+N8kErXWkA/OychAFivMPPjDQg3Gr0IThLtmv0DmsjkQpaIhfXiUU2BgQIySMaYlo L0O28b4DF9K9mBTUnBu04oxGw1arGgTWR96dio029DOidwt9QSPDBbSc/UAYlKRBRjDu lkyeeJvtaZ8QcMjVeO3dONR3tY3a/AnBbsHpITB5AfsO99WFoJuhGxFoOAfmd1/dIc17 mq0hu++lKk+DgPU2SiIAI24KfFAzaHTT2FKjDlXwQX0ocRWxM3qj2mjhoWGfJ5zD4B75 hTzZnSJlbLyBXy7DH5vIVFgLTfPq67T/OXBnwgQY31z69VT6qgcmvs1UEuwCjEkMh7Ni Z7rw== Return-Path: Received: from [192.168.0.41] (184-96-248-45.hlrn.qwest.net. [184.96.248.45]) by smtp.gmail.com with ESMTPSA id c18sm17158151vsl.25.2019.07.23.09.20.27 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jul 2019 09:20:27 -0700 (PDT) Subject: Re: [PATCH] PR91195: fix -Wmaybe-uninitialized warning for conditional store optimization To: JiangNing OS , "gcc-patches@gcc.gnu.org" References: From: Martin Sebor Message-ID: Date: Tue, 23 Jul 2019 16:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-07/txt/msg01526.txt.bz2 On 7/22/19 10:26 PM, JiangNing OS wrote: > This patch is to fix PR91195. Is it OK for trunk? > > diff --git a/gcc/ChangeLog b/gcc/ChangeLog > index 711a31ea597..4db36644160 100644 > --- a/gcc/ChangeLog > +++ b/gcc/ChangeLog > @@ -1,3 +1,9 @@ > +2019-07-22 Jiangning Liu > + > + PR middle-end/91195 > + * tree-ssa-phiopt.c (cond_store_replacement): Work around > + -Wmaybe-uninitialized warning. > + > 2019-07-22 Stafford Horne > > * config/or1k/or1k.c (or1k_expand_compare): Check for int before > diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c > index b64bde695f4..7a86007d087 100644 > --- a/gcc/tree-ssa-phiopt.c > +++ b/gcc/tree-ssa-phiopt.c > @@ -2240,6 +2240,14 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, > tree base = get_base_address (lhs); > if (!auto_var_p (base) || TREE_ADDRESSABLE (base)) > return false; > + > + /* The transformation below will inherently introduce a memory load, > + for which LHS may not be initialized yet if it is not in NOTRAP, > + so a -Wmaybe-uninitialized warning message could be triggered. > + Since it's a bit hard to have a very accurate uninitialization > + analysis to memory reference, we disable the warning here to avoid > + confusion. */ > + TREE_NO_WARNING (lhs) = 1; The no-warning bit is sometimes (typically?) set by the middle-end after a warning has been issued, to avoid triggering other warnings down the line for an already diagnosed expression. Unless it's done just for the purposes of a single pass and the bit is cleared afterwards, using it to avoid potential false positives doesn't seem like a robust solution. It will mask warnings for constructs that have been determined to be invalid. FWIW, the middle-end is susceptible to quite a few false positives that would nice to avoid. We have discussed various approaches to the problem but setting the no-warning bit seems like too blunt of an instrument. Martin