From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by sourceware.org (Postfix) with ESMTPS id 209FB3858C39 for ; Sun, 14 Nov 2021 05:48:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 209FB3858C39 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 7747234213C; Sun, 14 Nov 2021 05:48:51 +0000 (UTC) Received: from pdx1-sub0-mail-a306.dreamhost.com (100-96-17-73.trex.outbound.svc.cluster.local [100.96.17.73]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 00FC1342275; Sun, 14 Nov 2021 05:48:50 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a306.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.96.17.73 (trex/6.4.3); Sun, 14 Nov 2021 05:48:51 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Arithmetic-Well-Made: 49febf282b3ccdc8_1636868931228_3816700227 X-MC-Loop-Signature: 1636868931227:1149109274 X-MC-Ingress-Time: 1636868931227 Received: from [192.168.1.174] (unknown [1.186.121.107]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a306.dreamhost.com (Postfix) with ESMTPSA id 4HsLwd5D9Mz36; Sat, 13 Nov 2021 21:48:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1636868930; bh=KnP9TtUlgCXXRAES9O284jmmIm8=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=JAgE//gYY+GaLSdQBSNer49uUnL3qpVYErjuLMyc2NibGTPaOzlRP3bJrXN7yj17R B8QZ8uVQFzrQVnHg4EROOs4cn0APoQeBbl5C4uVNGPGGjRzXGHSKk6++ZQT6aQB8SL 2oK96n47HLHpPikbMl9gVrWLS4cR4Km2vY8CWR/Y= Message-ID: <3d477ffe-1db4-1aa3-b72c-c16c02de0654@gotplt.org> Date: Sun, 14 Nov 2021 11:18:44 +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 1/3] gimple-fold: Transform stp*cpy_chk to str*cpy directly Content-Language: en-US To: Prathamesh Kulkarni Cc: gcc-patches@gcc.gnu.org References: <20211111194116.1626980-1-siddhesh@gotplt.org> <20211111194116.1626980-2-siddhesh@gotplt.org> From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3037.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL, 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: Sun, 14 Nov 2021 05:48:55 -0000 On 11/12/21 22:46, Prathamesh Kulkarni wrote: > On Fri, 12 Nov 2021 at 01:12, Siddhesh Poyarekar wrote: >> >> Avoid going through another folding cycle and use the ignore flag to >> directly transform BUILT_IN_STPCPY_CHK to BUILT_IN_STRCPY when set, >> likewise for BUILT_IN_STPNCPY_CHK to BUILT_IN_STPNCPY. >> >> Dump the transformation in dump_file so that we can verify in tests that >> the direct transformation actually happened. >> >> gcc/ChangeLog: >> >> * gimple-fold.c (gimple_fold_builtin_stxcpy_chk, >> gimple_fold_builtin_stxncpy_chk): Use BUILT_IN_STRNCPY if return >> value is not used. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.dg/fold-stringops.c: New test. >> >> Signed-off-by: Siddhesh Poyarekar >> --- >> gcc/gimple-fold.c | 50 +++++++++++++++++-------- >> gcc/testsuite/gcc.dg/fold-stringops-1.c | 23 ++++++++++++ >> 2 files changed, 57 insertions(+), 16 deletions(-) >> create mode 100644 gcc/testsuite/gcc.dg/fold-stringops-1.c >> >> diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c >> index 6e25a7c05db..92e15784803 100644 >> --- a/gcc/gimple-fold.c >> +++ b/gcc/gimple-fold.c >> @@ -3088,6 +3088,19 @@ gimple_fold_builtin_memory_chk (gimple_stmt_iterator *gsi, >> return true; >> } >> >> +static void >> +dump_transformation (gimple *from, gimple *to) > I assume that both from and to will always be builtin calls ? > In that case, perhaps better to use gcall * here (and in rest of patch). > Also, needs a top-level comment describing the function. >> +{ >> + if (dump_file && (dump_flags & TDF_DETAILS)) > Perhaps better to use dump_enabled_p ? >> + { >> + fprintf (dump_file, "transformed "); > Perhaps use dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, ...) ? > I think you can use gimple_location to get the location. > Thanks, I'll fix these up. Siddhesh