From patchwork Mon Oct 18 04:24:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1542379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gotplt.org header.i=@gotplt.org header.a=rsa-sha1 header.s=gotplt.org header.b=c+gAGoo7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HXkLr062xz9s1l for ; Mon, 18 Oct 2021 15:25:23 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4947D385800D for ; Mon, 18 Oct 2021 04:25:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by sourceware.org (Postfix) with ESMTPS id 8F81A3858D28 for ; Mon, 18 Oct 2021 04:25:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F81A3858D28 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 36C1092082A for ; Mon, 18 Oct 2021 04:25:04 +0000 (UTC) Received: from pdx1-sub0-mail-a65.g.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 56610920760 for ; Mon, 18 Oct 2021 04:25:03 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a65.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.114.12.82 (trex/6.4.3); Mon, 18 Oct 2021 04:25:04 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Name-Tangy: 2013c078548a66b3_1634531104058_347104062 X-MC-Loop-Signature: 1634531104058:987087510 X-MC-Ingress-Time: 1634531104058 Received: from pdx1-sub0-mail-a65.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a65.g.dreamhost.com (Postfix) with ESMTP id F19DC7F721 for ; Sun, 17 Oct 2021 21:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gotplt.org; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=gotplt.org; bh=wD1/uzkYgStTkFvEZAVN3uor/vA=; b=c+gAGoo74R8lyL ML0/1PQBNt+ZCBerFuTuSV1bw1wqk6eSqyNFMPPaIBv/F2RSf65LFwxNgvyy7ZWc jD2ELcuu12YEoA95DfjEkP+nuMkhyLvtH8hvm4q+Yloo09rScdZUzFReq7dAjmak Ol9K+c2YEQOZZmijbQK+Xz2BijQ3Y= Received: from rhbox.redhat.com (unknown [1.186.123.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a65.g.dreamhost.com (Postfix) with ESMTPSA id D01D77FAA3 for ; Sun, 17 Oct 2021 21:25:00 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a65 From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-object-size: Avoid unnecessary processing of __builtin_object_size Date: Mon, 18 Oct 2021 09:54:38 +0530 Message-Id: <20211018042438.803964-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3037.2 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, RCVD_IN_SORBS_WEB, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This is a minor cleanup to bail out early if the result of __builtin_object_size is not assigned to anything and avoid initializing the object size arrays. gcc/ChangeLog: * tree-object-size (object_sizes_execute): Consolidate LHS null check and do it early. Signed-off-by: Siddhesh Poyarekar --- gcc/tree-object-size.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index 6a4dc724f34..46a976dfe10 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -1298,6 +1298,10 @@ object_sizes_execute (function *fun, bool insert_min_max_p) if (!gimple_call_builtin_p (call, BUILT_IN_OBJECT_SIZE)) continue; + tree lhs = gimple_call_lhs (call); + if (!lhs) + continue; + init_object_sizes (); /* If insert_min_max_p, only attempt to fold @@ -1312,11 +1316,9 @@ object_sizes_execute (function *fun, bool insert_min_max_p) { unsigned HOST_WIDE_INT object_size_type = tree_to_uhwi (ost); tree ptr = gimple_call_arg (call, 0); - tree lhs = gimple_call_lhs (call); if ((object_size_type == 1 || object_size_type == 3) && (TREE_CODE (ptr) == ADDR_EXPR - || TREE_CODE (ptr) == SSA_NAME) - && lhs) + || TREE_CODE (ptr) == SSA_NAME)) { tree type = TREE_TYPE (lhs); unsigned HOST_WIDE_INT bytes; @@ -1339,10 +1341,6 @@ object_sizes_execute (function *fun, bool insert_min_max_p) continue; } - tree lhs = gimple_call_lhs (call); - if (!lhs) - continue; - result = gimple_fold_stmt_to_constant (call, do_valueize); if (!result) {