From patchwork Tue Jun 15 05:59:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1491987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 ozlabs.org (Postfix) with ESMTPS id 4G3yNl6V2bz9sTD for ; Tue, 15 Jun 2021 16:00:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1F78F3986C21 for ; Tue, 15 Jun 2021 06:00:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (tbsaunde.org [66.228.47.254]) by sourceware.org (Postfix) with ESMTP id 5C6F53986C0D for ; Tue, 15 Jun 2021 05:59:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C6F53986C0D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tbsaunde.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tbsaunde.org Received: from caber.home (pool-108-24-42-131.cmdnnj.fios.verizon.net [108.24.42.131]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 20D28C085; Tue, 15 Jun 2021 05:59:54 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/6] return auto_vec from cgraph_node::collect_callers Date: Tue, 15 Jun 2021 01:59:18 -0400 Message-Id: <20210615055922.27205-2-tbsaunde@tbsaunde.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210615055922.27205-1-tbsaunde@tbsaunde.org> References: <20210615055922.27205-1-tbsaunde@tbsaunde.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Trevor Saunders Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This ensures the callers of collect_callers () take ownership of the vector and free it when appropriate. Signed-off-by: Trevor Saunders bootstrapped and regtested on x86_64-linux-gnu, ok? gcc/ChangeLog: * cgraph.c (cgraph_node::collect_callers): Return auto_vec. * cgraph.h (cgraph_node::collect_callers): Likewise. * ipa-cp.c (create_specialized_node): Adjust. (decide_about_value): Likewise. (decide_whether_version_node): Likewise. * ipa-sra.c (process_isra_node_results): Likewise. --- gcc/cgraph.c | 4 ++-- gcc/cgraph.h | 2 +- gcc/ipa-cp.c | 7 +++---- gcc/ipa-sra.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index d7c78d518bc..abe4e3ebfb3 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3074,10 +3074,10 @@ collect_callers_of_node_1 (cgraph_node *node, void *data) /* Collect all callers of cgraph_node and its aliases that are known to lead to cgraph_node (i.e. are not overwritable). */ -vec +auto_vec cgraph_node::collect_callers (void) { - vec redirect_callers = vNULL; + auto_vec redirect_callers; call_for_symbol_thunks_and_aliases (collect_callers_of_node_1, &redirect_callers, false); return redirect_callers; diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 4a1f89920f5..9f4338fdf87 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -1139,7 +1139,7 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node /* Collect all callers of cgraph_node and its aliases that are known to lead to NODE (i.e. are not overwritable) and that are not thunks. */ - vec collect_callers (void); + auto_vec collect_callers (void); /* Remove all callers from the node. */ void remove_callers (void); diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 2cae69e5a1b..57c18af2bab 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -4527,7 +4527,7 @@ create_specialized_node (struct cgraph_node *node, vec known_csts, vec known_contexts, struct ipa_agg_replacement_value *aggvals, - vec callers) + vec &callers) { ipa_node_params *new_info, *info = ipa_node_params_sum->get (node); vec *replace_trees = NULL; @@ -4672,7 +4672,6 @@ create_specialized_node (struct cgraph_node *node, ipcp_discover_new_direct_edges (new_node, known_csts, known_contexts, aggvals); - callers.release (); return new_node; } @@ -5562,6 +5561,7 @@ decide_about_value (struct cgraph_node *node, int index, HOST_WIDE_INT offset, offset, val->value)); val->spec_node = create_specialized_node (node, known_csts, known_contexts, aggvals, callers); + callers.release (); overall_size += val->local_size_cost; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " overall size reached %li\n", @@ -5638,7 +5638,7 @@ decide_whether_version_node (struct cgraph_node *node) } struct cgraph_node *clone; - vec callers = node->collect_callers (); + auto_vec callers = node->collect_callers (); for (int i = callers.length () - 1; i >= 0; i--) { @@ -5654,7 +5654,6 @@ decide_whether_version_node (struct cgraph_node *node) /* If node is not called by anyone, or all its caller edges are self-recursive, the node is not really in use, no need to do cloning. */ - callers.release (); info->do_clone_for_all_contexts = false; return ret; } diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c index 3f90d4d81b6..3272daf56e4 100644 --- a/gcc/ipa-sra.c +++ b/gcc/ipa-sra.c @@ -3755,7 +3755,7 @@ process_isra_node_results (cgraph_node *node, unsigned &suffix_counter = clone_num_suffixes->get_or_insert ( IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME ( node->decl))); - vec callers = node->collect_callers (); + auto_vec callers = node->collect_callers (); cgraph_node *new_node = node->create_virtual_clone (callers, NULL, new_adjustments, "isra", suffix_counter);