From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from brown.birch.relay.mailchannels.net (brown.birch.relay.mailchannels.net [23.83.209.23]) by sourceware.org (Postfix) with ESMTPS id 26DE0385842E for ; Mon, 15 Nov 2021 22:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 26DE0385842E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 94550202237; Mon, 15 Nov 2021 22:53:19 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0F8DE20226B; Mon, 15 Nov 2021 22:53:19 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.111.70.133 (trex/6.4.3); Mon, 15 Nov 2021 22:53:19 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Towering-Abiding: 463bc7286823b67f_1637016799322_3143616191 X-MC-Loop-Signature: 1637016799322:603566560 X-MC-Ingress-Time: 1637016799322 Received: from [192.168.1.174] (unknown [1.186.223.29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4HtPcF5pBDz3N; Mon, 15 Nov 2021 14:53:17 -0800 (PST) Message-ID: <9ec6de5e-9ac0-af0c-a2c9-70325dc03ed1@gotplt.org> Date: Tue, 16 Nov 2021 04:23:12 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v2 2/3] gimple-fold: Use ranges to simplify _chk calls Content-Language: en-US To: Jeff Law , gcc-patches@gcc.gnu.org References: <20211111194116.1626980-1-siddhesh@gotplt.org> <20211115173315.1857598-1-siddhesh@gotplt.org> <20211115173315.1857598-3-siddhesh@gotplt.org> From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Mon, 15 Nov 2021 22:53:22 -0000 On 11/16/21 01:55, Jeff Law wrote: > > > On 11/15/2021 10:33 AM, Siddhesh Poyarekar wrote: >> Instead of comparing LEN and SIZE only if they are constants, use their >> ranges to decide if LEN will always be lower than or same as SIZE. >> >> This change ends up putting the stringop-overflow warning line number >> against the strcpy implementation, so adjust the warning check to be >> line number agnostic. >> >> gcc/ChangeLog: >> >>     * gimple-fold.c (known_lower): New function. >>     (gimple_fold_builtin_strncat_chk, >>     gimple_fold_builtin_memory_chk, gimple_fold_builtin_stxcpy_chk, >>     gimple_fold_builtin_stxncpy_chk, >>     gimple_fold_builtin_snprintf_chk, >>     gimple_fold_builtin_sprintf_chk): Use it. >> >> gcc/testsuite/ChangeLog: >> >>     * gcc.dg/Wobjsize-1.c: Make warning change line agnostic. >>     * gcc.dg/builtin-chk-fold.c: New test. >> >> > >> @@ -3024,39 +3040,24 @@ gimple_fold_builtin_memory_chk >> (gimple_stmt_iterator *gsi, >>       } >>       } >> -  if (! tree_fits_uhwi_p (size)) >> -    return false; >> - >>     tree maxlen = get_maxval_strlen (len, SRK_INT_VALUE); >> -  if (! integer_all_onesp (size)) >> +  if (! integer_all_onesp (size) >> +      && !known_lower (stmt, len, size) && !known_lower (stmt, >> maxlen, size)) > Formatting it.  Move the trailing && !known_lower (...) to its own line. > > OK with the formatting nit fixed. Thanks, I fixed the nit and pushed the series. Siddhesh