From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36474 invoked by alias); 17 Jan 2019 01:14:19 -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 36457 invoked by uid 89); 17 Jan 2019 01:14:18 -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=stage1, al, delaying 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; Thu, 17 Jan 2019 01:14:16 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D713A0498; Thu, 17 Jan 2019 01:14:15 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-2.rdu2.redhat.com [10.10.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 248EE2B9F3; Thu, 17 Jan 2019 01:14:13 +0000 (UTC) Subject: Re: [PATCH] avoid issuing -Warray-bounds during folding (PR 88800) To: Martin Sebor , Richard Biener Cc: "gcc-patches@gcc.gnu.org" References: <37e931ad-17de-552e-8c96-854233884e6a@gmail.com> <76eda7b0-f5d6-9312-63ea-a344949689e6@gmail.com> From: Jeff Law Openpgp: preference=signencrypt Message-ID: <7c0a5eb6-05de-1593-87d4-7944ce968e06@redhat.com> Date: Thu, 17 Jan 2019 01:14:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <76eda7b0-f5d6-9312-63ea-a344949689e6@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00971.txt.bz2 On 1/15/19 8:21 AM, Martin Sebor wrote: > On 1/15/19 4:07 AM, Richard Biener wrote: >> On Tue, Jan 15, 2019 at 1:08 AM Martin Sebor wrote: >>> >>> The gimple_fold_builtin_memory_op() function folds calls to memcpy >>> and similar to MEM_REF when the size of the copy is a small power >>> of 2, but it does so without considering whether the copy might >>> write (or read) past the end of one of the objects.  To detect >>> these kinds of errors (and help distinguish them from -Westrict) >>> the folder calls into the wrestrict pass and lets it diagnose them. >>> Unfortunately, that can lead to false positives for even some fairly >>> straightforward code that is ultimately found to be unreachable. >>> PR 88800 is a report of one such problem. >>> >>> To avoid these false positives the attached patch adjusts >>> the function to avoid issuing -Warray-bounds for out-of-bounds >>> calls to memcpy et al.  Instead, the patch disables the folding >>> of such invalid calls (and only those).  Those that are not >>> eliminated during DCE or other subsequent passes are eventually >>> diagnosed by the wrestrict pass. >>> >>> Since this change required removing the dependency of the detection >>> on the warning options (originally done as a micro-optimization to >>> avoid spending compile-time cycles on something that wasn't needed) >>> the patch also adds tests to verify that code generation is not >>> affected as a result of warnings being enabled or disabled.  With >>> the patch as is, the invalid memcpy calls end up emitted (currently >>> they are folded into equally invalid MEM_REFs).  At some point, >>> I'd like us to consider whether they should be replaced with traps >>> (possibly under the control of  as has been proposed a number of >>> times in the past.  If/when that's done, these tests will need to >>> be adjusted to look for traps instead. >>> >>> Tested on x86_64-linux. >> >> I've said in the past that I feel delaying of folding is wrong. >> >> To understand, the PR is about emitting a warning for out-of-bound >> accesses in a dead code region? > > Yes.  I am keeping in my mind your preference of not delaying > the folding of valid code. > >> >> If we think delaying/disablign the folding is the way to go the >> patch looks OK. > > I do, at least for now.  I'm taking this as your approval to commit > the patch (please let me know if you didn't mean it that way). Note we are in stage4, so we're supposed to be addressing regression bugfixes and documentation issues. So I think Richi needs to be explicit about whether or not he wants this in gcc-9 or if it should defer to gcc-10. I have no technical objections to the patch and would easily ack it in stage1 or stage3. Jeff