From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 20D663858400 for ; Mon, 18 Oct 2021 09:57:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 20D663858400 Received: by mail-ed1-x52e.google.com with SMTP id w19so68530872edd.2 for ; Mon, 18 Oct 2021 02:57:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=31SDM3l+Iim2fb3onlBqItBu6SGHUae4E8XYbe5mfhw=; b=MdObExBcVYuA0J/VPoS18wbfBJGzvK0mEwoyuODdXKfidFIHncvPiqUc7EVgj2ft8u 9zKIitDUtCiNdYxK3ECouOWChzcTa9w3llVq50F84bpWdh2eF+BBR9k+mYVYZt1cpulF 7iiZibT/QWh+GwYf+TTLXZeGnhhAxLx37X2C6WStLPA6FELnLcMZcUlJU5K+rON2aR15 Z+6jevh/aEU4QVS/3yxuO7SpTP6kTvFEzquWpzRMMgGffhq6MjYhh0zABh2dLngMkS9A E3CuM4o7O9w1cbt8IaV2OYUR8JFK88etIPWsDZabKu7QFZ1H7dNG0duXJOGk52No98Bq x+Xw== X-Gm-Message-State: AOAM531CtH4lnfNTHZrbHkNEJGIpaYknxMtNRk0bLw1O1+oYgutUxSDK f66a1FzzCOJbzgAikSj1fcCUJ22zCNCSYZvvF27HfmVW X-Google-Smtp-Source: ABdhPJz68J4KnjVwGS4cahDqGE+XdNUPbiNsHph9i2O3m8RJw/PbNeCMa9BFZJLKJ2lPCeaUQWiJXJy8Q8XodXWfZ/Q= X-Received: by 2002:a50:e0c3:: with SMTP id j3mr42488542edl.97.1634551050277; Mon, 18 Oct 2021 02:57:30 -0700 (PDT) MIME-Version: 1.0 References: <20211018042438.803964-1-siddhesh@gotplt.org> In-Reply-To: <20211018042438.803964-1-siddhesh@gotplt.org> From: Richard Biener Date: Mon, 18 Oct 2021 11:57:19 +0200 Message-ID: Subject: Re: [PATCH] tree-object-size: Avoid unnecessary processing of __builtin_object_size To: Siddhesh Poyarekar Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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, 18 Oct 2021 09:57:33 -0000 On Mon, Oct 18, 2021 at 6:25 AM Siddhesh Poyarekar wrote: > > 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. OK. Thanks, Richard. > 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) > { > -- > 2.31.1 >