From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52782 invoked by alias); 17 Sep 2018 17:24:42 -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 52585 invoked by uid 89); 17 Sep 2018 17:24:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Sep 2018 17:24:26 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0E83C050002; Mon, 17 Sep 2018 17:24:18 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-75.rdu2.redhat.com [10.10.112.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E6117EED4; Mon, 17 Sep 2018 17:24:17 +0000 (UTC) Subject: Re: [PATCH] look harder for MEM_REF operand equality to avoid -Wstringop-truncation (PR 84561) To: Bernd Edlinger , Martin Sebor Cc: Richard Biener , "gcc-patches@gcc.gnu.org" References: From: Jeff Law Openpgp: preference=signencrypt Message-ID: <84559a68-1a5c-45e8-b6f1-7eb86ae12e3e@redhat.com> Date: Mon, 17 Sep 2018 17:34:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00885.txt.bz2 On 9/15/18 2:14 AM, Bernd Edlinger wrote: > On 9/14/18, Martin Sebor wrote: >> As I said above, this happens during the dom walk in the ccp >> pass: >> >> substitute_and_fold_dom_walker walker (CDI_DOMINATORS, this); >> walker.walk (ENTRY_BLOCK_PTR_FOR_FN (cfun)); >> >> The warning is issued during the walker.walk() call as >> strncpy is being folded into memcpy. The prior assignments are >> only propagated later, when the next statement after the strncpy >> call is reached. It happens in >> substitute_and_fold_dom_walker::before_dom_children(). So during >> the strncpy folding we see the next statement as: >> >> MEM[(struct S *)_1].a[n_7] = 0; >> >> After the strncpy call is transformed to memcpy, the assignment >> above is transformed to >> >> MEM[(struct S *)_8].a[3] = 0; >> >> >>> If they're only discovered as copies within the pass where you're trying >>> to issue the diagnostic, then you'd want to see if the pass has any >>> internal structures that tell you about equivalences. >> >> >> I don't know if this is possible. I don't see any APIs in >> tree-ssa-propagate.h that would let me query the internal data >> somehow to find out during folding (when the warning is issued). > > > Well, > > if I see this right, the CCP is doing tree transformations > while from the folding of strncpy the predicate maybe_diag_stxncpy_trunc > is called, and sees inconsistent information, in the tree, > and therefore it issues a warning. > > I understand that walking the references is fragile at least > in this state. > > But why not just prevent warnings when this is called from CCP? > > > Like this? > > Bootstrapped and reg-tested on x86_64-pc-linux-gnu. > Is it OK for trunk? No. That's just hacking around the real problem. jeff