From patchwork Wed Nov 10 17:47:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 47418 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC8033857830 for ; Wed, 10 Nov 2021 17:48:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cross.elm.relay.mailchannels.net (cross.elm.relay.mailchannels.net [23.83.212.46]) by sourceware.org (Postfix) with ESMTPS id E12493858400 for ; Wed, 10 Nov 2021 17:47:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E12493858400 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 D27CE82053B for ; Wed, 10 Nov 2021 17:47:43 +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 7390B820FBD for ; Wed, 10 Nov 2021 17:47:43 +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.120.81.154 (trex/6.4.3); Wed, 10 Nov 2021 17:47:43 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Rock-Irritate: 057452690d2077bb_1636566463717_2492105331 X-MC-Loop-Signature: 1636566463717:3122729237 X-MC-Ingress-Time: 1636566463717 Received: from rhbox.redhat.com (unknown [1.186.121.127]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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-a305.dreamhost.com (Postfix) with ESMTPSA id 4HqC3y1vWkz3c for ; Wed, 10 Nov 2021 09:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1636566463; bh=8UMnxnwyB5dwN27wqhKv91GU/KQ=; h=From:To:Subject:Date:Content-Transfer-Encoding; b=Zuar7sP/cqqyaMRllbpMYF09d0hCrWJD3yBolFv+xiRyQ81/UN2pVU6BN4Hn8isIJ +rPYsKudrVF9pk2vAk3iIHf3F26EgxX5pjtfgM2SjBvDOkwktuzoG3HKtFrkAz/aoE BXQDhrcMiz+DeJh9UOD5yC7WE9JsxSYwQYCFF2Hg= From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH] gimple-fold: Transform stp*cpy_chk to strcpy Date: Wed, 10 Nov 2021 23:17:28 +0530 Message-Id: <20211110174728.3932930-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3038.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Use the ignore flag to transform BUILT_IN_STPCPY_CHK to BUILT_IN_STRCPY when set. This transformation will happen in a subsequent fold anyway but do it right away and save the additional effort. 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. Signed-off-by: Siddhesh Poyarekar --- gcc/gimple-fold.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 74c9ce4bdc8..cadccfe3010 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -3176,7 +3176,7 @@ gimple_fold_builtin_stxcpy_chk (gimple_stmt_iterator *gsi, } /* If __builtin_st{r,p}cpy_chk is used, assume st{r,p}cpy is available. */ - fn = builtin_decl_explicit (fcode == BUILT_IN_STPCPY_CHK + fn = builtin_decl_explicit (fcode == BUILT_IN_STPCPY_CHK && !ignore ? BUILT_IN_STPCPY : BUILT_IN_STRCPY); if (!fn) return false; @@ -3220,7 +3220,7 @@ gimple_fold_builtin_stxncpy_chk (gimple_stmt_iterator *gsi, return false; /* If __builtin_st{r,p}ncpy_chk is used, assume st{r,p}ncpy is available. */ - fn = builtin_decl_explicit (fcode == BUILT_IN_STPNCPY_CHK + fn = builtin_decl_explicit (fcode == BUILT_IN_STPNCPY_CHK && !ignore ? BUILT_IN_STPNCPY : BUILT_IN_STRNCPY); if (!fn) return false;