From patchwork Tue Jun 15 05:59:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1491986 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.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 ozlabs.org (Postfix) with ESMTPS id 4G3yN162jNz9sW7 for ; Tue, 15 Jun 2021 16:00:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45EBE39874C0 for ; Tue, 15 Jun 2021 06:00:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (unknown [IPv6:2600:3c03::f03c:91ff:fe6e:c625]) by sourceware.org (Postfix) with ESMTP id B36E7385802B for ; Tue, 15 Jun 2021 05:59:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B36E7385802B 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 22548C0DE; Tue, 15 Jun 2021 05:59:48 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/6] auto_vec copy/move improvements Date: Tue, 15 Jun 2021 01:59:17 -0400 Message-Id: <20210615055922.27205-1-tbsaunde@tbsaunde.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_SBL_CSS, 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" - Unfortunately using_auto_storage () needs to handle m_vec being null. - Handle self move of an auto_vec to itself. - punt on defining copy or move operators for auto_vec with inline storage, until there is a need for them and we can decide what semantics they should have. - Make sure auto_vec defines the classes move constructor and assignment operator, as well as ones taking vec, so the compiler does not generate them for us. Per https://en.cppreference.com/w/cpp/language/move_constructor the ones taking vec do not count as the classes move constructor or assignment operator, but we want them as well to assign a plain vec to a auto_vec. - Explicitly delete auto_vec's copy constructor and assignment operator. This prevents unintentional expenssive coppies of the vector and makes it clear when coppies are needed that that is what is intended. When it is necessary to copy a vector copy () can be used. Signed-off-by: Trevor Saunders bootstrapped and regtested on x86_64-linux-gnu, ok? gcc/ChangeLog: * vec.h (vl_ptr>::using_auto_storage): Handle null m_vec. (auto_vec::auto_vec): Define move constructor, and delete copy constructor. (auto_vec::operator=): Define move assignment and delete copy assignment. (auto_vec::auto_vec): Delete copy and move constructors. (auto_vec::operator=): Delete copy and move assignment. --- gcc/vec.h | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/gcc/vec.h b/gcc/vec.h index 193377cb69c..ceefa67e1ad 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -1549,6 +1549,16 @@ public: this->release (); } + // Punt for now on moving auto_vec with inline storage. For now this + // prevents people creating dangling pointers or the like. + auto_vec (auto_vec &&) = delete; + auto_vec &operator= (auto_vec &&) = delete; + + // Punt for now on the inline storage, and you probably don't want to copy + // vectors anyway. If you really must copy a vector use copy (). + auto_vec(const auto_vec &) = delete; + auto_vec &operator= (const auto_vec &) = delete; + private: vec m_auto; T m_data[MAX (N - 1, 1)]; @@ -1570,14 +1580,43 @@ public: this->m_vec = r.m_vec; r.m_vec = NULL; } + + auto_vec (auto_vec &&r) + { + gcc_assert (!r.using_auto_storage ()); + this->m_vec = r.m_vec; + r.m_vec = NULL; + } + auto_vec& operator= (vec&& r) { + if (this == &r) + return *this; + + gcc_assert (!r.using_auto_storage ()); + this->release (); + this->m_vec = r.m_vec; + r.m_vec = NULL; + return *this; + } + + auto_vec& operator= (auto_vec &&r) + { + if (this == &r) + return *this; + gcc_assert (!r.using_auto_storage ()); this->release (); this->m_vec = r.m_vec; r.m_vec = NULL; return *this; } + + // You probably don't want to copy a vector, so these are deleted to prevent + // unintentional use. If you really need a copy of the vectors contents you + // can use copy (). + auto_vec(const auto_vec &) = delete; + auto_vec &operator= (const auto_vec &) = delete; }; @@ -2147,7 +2186,7 @@ template inline bool vec::using_auto_storage () const { - return m_vec->m_vecpfx.m_using_auto_storage; + return m_vec ? m_vec->m_vecpfx.m_using_auto_storage : false; } /* Release VEC and call release of all element vectors. */ 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); From patchwork Tue Jun 15 05:59:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1491988 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 4G3yPK0QgWz9sW7 for ; Tue, 15 Jun 2021 16:01:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A558D3987C28 for ; Tue, 15 Jun 2021 06:01:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (unknown [IPv6:2600:3c03::f03c:91ff:fe6e:c625]) by sourceware.org (Postfix) with ESMTP id 176903986831 for ; Tue, 15 Jun 2021 05:59:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 176903986831 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 EC6B3C085; Tue, 15 Jun 2021 05:59:55 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/6] return auto_vec from get_loop_hot_path Date: Tue, 15 Jun 2021 01:59:19 -0400 Message-Id: <20210615055922.27205-3-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=-9.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_SBL_CSS, 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 callers take ownership of the returned vector. Signed-off-by: Trevor Saunders bootstrapped and regtested on x86_64-linux-gnu, ok? gcc/ChangeLog: * cfgloop.h (get_loop_hot_path): Return auto_vec. * cfgloopanal.c (get_loop_hot_path): Likewise. * tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise. --- gcc/cfgloop.h | 2 +- gcc/cfgloopanal.c | 2 +- gcc/tree-ssa-loop-ivcanon.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 113241da130..5e699276c88 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -840,7 +840,7 @@ enum extern void doloop_optimize_loops (void); extern void move_loop_invariants (void); -extern vec get_loop_hot_path (const class loop *loop); +extern auto_vec get_loop_hot_path (const class loop *loop); /* Returns the outermost loop of the loop nest that contains LOOP.*/ static inline class loop * diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index d0eade3dd34..e7b7ae2163e 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -500,7 +500,7 @@ single_likely_exit (class loop *loop, vec exits) order against direction of edges from latch. Specially, if header != latch, latch is the 1-st block. */ -vec +auto_vec get_loop_hot_path (const class loop *loop) { basic_block bb = loop->header; diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 3f9e9d0869f..b1971f83544 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -218,7 +218,7 @@ tree_estimate_loop_size (class loop *loop, edge exit, edge edge_to_cancel, gimple_stmt_iterator gsi; unsigned int i; bool after_exit; - vec path = get_loop_hot_path (loop); + auto_vec path = get_loop_hot_path (loop); size->overall = 0; size->eliminated_by_peeling = 0; @@ -342,7 +342,6 @@ tree_estimate_loop_size (class loop *loop, edge exit, edge edge_to_cancel, - size->last_iteration_eliminated_by_peeling) > upper_bound) { free (body); - path.release (); return true; } } @@ -379,7 +378,7 @@ tree_estimate_loop_size (class loop *loop, edge exit, edge edge_to_cancel, size->num_branches_on_hot_path++; } } - path.release (); + if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "size: %i-%i, last_iteration: %i-%i\n", size->overall, size->eliminated_by_peeling, size->last_iteration, From patchwork Tue Jun 15 05:59:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1491989 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 4G3yPw0wBdz9sTD for ; Tue, 15 Jun 2021 16:01:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90CA43987C36 for ; Tue, 15 Jun 2021 06:01:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (unknown [IPv6:2600:3c03::f03c:91ff:fe6e:c625]) by sourceware.org (Postfix) with ESMTP id 667D73986C0C for ; Tue, 15 Jun 2021 05:59:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 667D73986C0C 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 40DD3C085; Tue, 15 Jun 2021 05:59:57 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/6] return auto_vec from get_dominated_by Date: Tue, 15 Jun 2021 01:59:20 -0400 Message-Id: <20210615055922.27205-4-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=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_SBL_CSS, 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" Signed-off-by: Trevor Saunders bootstrapped and regtested on x86_64-linux-gnu, ok? gcc/ChangeLog: * dominance.c (get_dominated_by): Return auto_vec. * dominance.h (get_dominated_by): Likewise. * auto-profile.c (afdo_find_equiv_class): Adjust. * cfgloopmanip.c (duplicate_loop_to_header_edge): Likewise. * loop-unroll.c (unroll_loop_runtime_iterations): Likewise. * tree-cfg.c (test_linear_chain): Likewise. (test_diamond): Likewise. --- gcc/auto-profile.c | 9 +++------ gcc/cfgloopmanip.c | 4 +--- gcc/dominance.c | 6 +++--- gcc/dominance.h | 2 +- gcc/loop-unroll.c | 12 +++--------- gcc/tree-cfg.c | 14 ++++++-------- 6 files changed, 17 insertions(+), 30 deletions(-) diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index ed788dc06a8..43d6fa0b1f0 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -1155,13 +1155,10 @@ afdo_find_equiv_class (bb_set *annotated_bb) FOR_ALL_BB_FN (bb, cfun) { - vec dom_bbs; - if (bb->aux != NULL) continue; bb->aux = bb; - dom_bbs = get_dominated_by (CDI_DOMINATORS, bb); - for (basic_block bb1 : dom_bbs) + for (basic_block bb1 : get_dominated_by (CDI_DOMINATORS, bb)) if (bb1->aux == NULL && dominated_by_p (CDI_POST_DOMINATORS, bb, bb1) && bb1->loop_father == bb->loop_father) { @@ -1172,8 +1169,8 @@ afdo_find_equiv_class (bb_set *annotated_bb) set_bb_annotated (bb, annotated_bb); } } - dom_bbs = get_dominated_by (CDI_POST_DOMINATORS, bb); - for (basic_block bb1 : dom_bbs) + + for (basic_block bb1 : get_dominated_by (CDI_POST_DOMINATORS, bb)) if (bb1->aux == NULL && dominated_by_p (CDI_DOMINATORS, bb, bb1) && bb1->loop_father == bb->loop_father) { diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c index 4a9ab74642c..e6df28036c4 100644 --- a/gcc/cfgloopmanip.c +++ b/gcc/cfgloopmanip.c @@ -1414,13 +1414,12 @@ duplicate_loop_to_header_edge (class loop *loop, edge e, for (i = 0; i < n; i++) { basic_block dominated, dom_bb; - vec dom_bbs; unsigned j; bb = bbs[i]; bb->aux = 0; - dom_bbs = get_dominated_by (CDI_DOMINATORS, bb); + auto_vec dom_bbs = get_dominated_by (CDI_DOMINATORS, bb); FOR_EACH_VEC_ELT (dom_bbs, j, dominated) { if (flow_bb_inside_loop_p (loop, dominated)) @@ -1429,7 +1428,6 @@ duplicate_loop_to_header_edge (class loop *loop, edge e, CDI_DOMINATORS, first_active[i], first_active_latch); set_immediate_dominator (CDI_DOMINATORS, dominated, dom_bb); } - dom_bbs.release (); } free (first_active); diff --git a/gcc/dominance.c b/gcc/dominance.c index 5fa172f3280..0e464cb7282 100644 --- a/gcc/dominance.c +++ b/gcc/dominance.c @@ -883,17 +883,17 @@ set_immediate_dominator (enum cdi_direction dir, basic_block bb, /* Returns the list of basic blocks immediately dominated by BB, in the direction DIR. */ -vec +auto_vec get_dominated_by (enum cdi_direction dir, basic_block bb) { unsigned int dir_index = dom_convert_dir_to_idx (dir); struct et_node *node = bb->dom[dir_index], *son = node->son, *ason; - vec bbs = vNULL; + auto_vec bbs; gcc_checking_assert (dom_computed[dir_index]); if (!son) - return vNULL; + return bbs; bbs.safe_push ((basic_block) son->data); for (ason = son->right; ason != son; ason = ason->right) diff --git a/gcc/dominance.h b/gcc/dominance.h index 4eeac59fc59..515a369aacf 100644 --- a/gcc/dominance.h +++ b/gcc/dominance.h @@ -46,7 +46,7 @@ extern void free_dominance_info_for_region (function *, extern basic_block get_immediate_dominator (enum cdi_direction, basic_block); extern void set_immediate_dominator (enum cdi_direction, basic_block, basic_block); -extern vec get_dominated_by (enum cdi_direction, basic_block); +extern auto_vec get_dominated_by (enum cdi_direction, basic_block); extern vec get_dominated_by_region (enum cdi_direction, basic_block *, unsigned); diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index 8b6fcf5074c..66d93487e29 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -884,7 +884,7 @@ unroll_loop_runtime_iterations (class loop *loop) { rtx old_niter, niter, tmp; rtx_insn *init_code, *branch_code; - unsigned i, j; + unsigned i; profile_probability p; basic_block preheader, *body, swtch, ezc_swtch = NULL; int may_exit_copy; @@ -908,15 +908,9 @@ unroll_loop_runtime_iterations (class loop *loop) body = get_loop_body (loop); for (i = 0; i < loop->num_nodes; i++) { - vec ldom; - basic_block bb; - - ldom = get_dominated_by (CDI_DOMINATORS, body[i]); - FOR_EACH_VEC_ELT (ldom, j, bb) + for (basic_block bb : get_dominated_by (CDI_DOMINATORS, body[i])) if (!flow_bb_inside_loop_p (loop, bb)) dom_bbs.safe_push (bb); - - ldom.release (); } free (body); @@ -1013,7 +1007,7 @@ unroll_loop_runtime_iterations (class loop *loop) gcc_assert (ok); /* Create item for switch. */ - j = n_peel - i - (extra_zero_check ? 0 : 1); + unsigned j = n_peel - i - (extra_zero_check ? 0 : 1); p = profile_probability::always ().apply_scale (1, i + 2); preheader = split_edge (loop_preheader_edge (loop)); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 02256580c98..6bdd1a561fd 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -9917,22 +9917,20 @@ test_linear_chain () calculate_dominance_info (CDI_DOMINATORS); ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_b)); ASSERT_EQ (bb_b, get_immediate_dominator (CDI_DOMINATORS, bb_c)); - vec dom_by_b = get_dominated_by (CDI_DOMINATORS, bb_b); + auto_vec dom_by_b = get_dominated_by (CDI_DOMINATORS, bb_b); ASSERT_EQ (1, dom_by_b.length ()); ASSERT_EQ (bb_c, dom_by_b[0]); free_dominance_info (CDI_DOMINATORS); - dom_by_b.release (); /* Similarly for post-dominance: each BB in our chain is post-dominated by the one after it. */ calculate_dominance_info (CDI_POST_DOMINATORS); ASSERT_EQ (bb_b, get_immediate_dominator (CDI_POST_DOMINATORS, bb_a)); ASSERT_EQ (bb_c, get_immediate_dominator (CDI_POST_DOMINATORS, bb_b)); - vec postdom_by_b = get_dominated_by (CDI_POST_DOMINATORS, bb_b); + auto_vec postdom_by_b = get_dominated_by (CDI_POST_DOMINATORS, bb_b); ASSERT_EQ (1, postdom_by_b.length ()); ASSERT_EQ (bb_a, postdom_by_b[0]); free_dominance_info (CDI_POST_DOMINATORS); - postdom_by_b.release (); pop_cfun (); } @@ -9991,10 +9989,10 @@ test_diamond () ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_b)); ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_c)); ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_d)); - vec dom_by_a = get_dominated_by (CDI_DOMINATORS, bb_a); + auto_vec dom_by_a = get_dominated_by (CDI_DOMINATORS, bb_a); ASSERT_EQ (3, dom_by_a.length ()); /* B, C, D, in some order. */ dom_by_a.release (); - vec dom_by_b = get_dominated_by (CDI_DOMINATORS, bb_b); + auto_vec dom_by_b = get_dominated_by (CDI_DOMINATORS, bb_b); ASSERT_EQ (0, dom_by_b.length ()); dom_by_b.release (); free_dominance_info (CDI_DOMINATORS); @@ -10004,10 +10002,10 @@ test_diamond () ASSERT_EQ (bb_d, get_immediate_dominator (CDI_POST_DOMINATORS, bb_a)); ASSERT_EQ (bb_d, get_immediate_dominator (CDI_POST_DOMINATORS, bb_b)); ASSERT_EQ (bb_d, get_immediate_dominator (CDI_POST_DOMINATORS, bb_c)); - vec postdom_by_d = get_dominated_by (CDI_POST_DOMINATORS, bb_d); + auto_vec postdom_by_d = get_dominated_by (CDI_POST_DOMINATORS, bb_d); ASSERT_EQ (3, postdom_by_d.length ()); /* A, B, C in some order. */ postdom_by_d.release (); - vec postdom_by_b = get_dominated_by (CDI_POST_DOMINATORS, bb_b); + auto_vec postdom_by_b = get_dominated_by (CDI_POST_DOMINATORS, bb_b); ASSERT_EQ (0, postdom_by_b.length ()); postdom_by_b.release (); free_dominance_info (CDI_POST_DOMINATORS); From patchwork Tue Jun 15 05:59:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1491990 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 4G3yQV3MM2z9sTD for ; Tue, 15 Jun 2021 16:02:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19D16398802B for ; Tue, 15 Jun 2021 06:02:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (unknown [IPv6:2600:3c03::f03c:91ff:fe6e:c625]) by sourceware.org (Postfix) with ESMTP id D5F88389681B for ; Tue, 15 Jun 2021 05:59:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5F88389681B 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 AD340C0DE; Tue, 15 Jun 2021 05:59:58 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 5/6] make get_domminated_by_region return a auto_vec Date: Tue, 15 Jun 2021 01:59:21 -0400 Message-Id: <20210615055922.27205-5-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=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_SBL_CSS, 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 makes it clear the caller owns the vector, and ensures it is cleaned up. Signed-off-by: Trevor Saunders bootstrapped and regtested on x86_64-linux-gnu, ok? gcc/ChangeLog: * dominance.c (get_dominated_by_region): Return auto_vec. * dominance.h (get_dominated_by_region): Likewise. * tree-cfg.c (gimple_duplicate_sese_region): Adjust. (gimple_duplicate_sese_tail): Likewise. (move_sese_region_to_fn): Likewise. --- gcc/dominance.c | 4 ++-- gcc/dominance.h | 2 +- gcc/tree-cfg.c | 18 +++++++----------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/gcc/dominance.c b/gcc/dominance.c index 0e464cb7282..4943102ff1d 100644 --- a/gcc/dominance.c +++ b/gcc/dominance.c @@ -906,13 +906,13 @@ get_dominated_by (enum cdi_direction dir, basic_block bb) direction DIR) by some block between N_REGION ones stored in REGION, except for blocks in the REGION itself. */ -vec +auto_vec get_dominated_by_region (enum cdi_direction dir, basic_block *region, unsigned n_region) { unsigned i; basic_block dom; - vec doms = vNULL; + auto_vec doms; for (i = 0; i < n_region; i++) region[i]->flags |= BB_DUPLICATED; diff --git a/gcc/dominance.h b/gcc/dominance.h index 515a369aacf..c74ad297c6a 100644 --- a/gcc/dominance.h +++ b/gcc/dominance.h @@ -47,7 +47,7 @@ extern basic_block get_immediate_dominator (enum cdi_direction, basic_block); extern void set_immediate_dominator (enum cdi_direction, basic_block, basic_block); extern auto_vec get_dominated_by (enum cdi_direction, basic_block); -extern vec get_dominated_by_region (enum cdi_direction, +extern auto_vec get_dominated_by_region (enum cdi_direction, basic_block *, unsigned); extern vec get_dominated_to_depth (enum cdi_direction, diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 6bdd1a561fd..c9403deed19 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6495,7 +6495,6 @@ gimple_duplicate_sese_region (edge entry, edge exit, bool free_region_copy = false, copying_header = false; class loop *loop = entry->dest->loop_father; edge exit_copy; - vec doms = vNULL; edge redirected; profile_count total_count = profile_count::uninitialized (); profile_count entry_count = profile_count::uninitialized (); @@ -6549,9 +6548,9 @@ gimple_duplicate_sese_region (edge entry, edge exit, /* Record blocks outside the region that are dominated by something inside. */ + auto_vec doms; if (update_dominance) { - doms.create (0); doms = get_dominated_by_region (CDI_DOMINATORS, region, n_region); } @@ -6596,7 +6595,6 @@ gimple_duplicate_sese_region (edge entry, edge exit, set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src); doms.safe_push (get_bb_original (entry->dest)); iterate_fix_dominators (CDI_DOMINATORS, doms, false); - doms.release (); } /* Add the other PHI node arguments. */ @@ -6662,7 +6660,6 @@ gimple_duplicate_sese_tail (edge entry, edge exit, class loop *loop = exit->dest->loop_father; class loop *orig_loop = entry->dest->loop_father; basic_block switch_bb, entry_bb, nentry_bb; - vec doms; profile_count total_count = profile_count::uninitialized (), exit_count = profile_count::uninitialized (); edge exits[2], nexits[2], e; @@ -6705,7 +6702,8 @@ gimple_duplicate_sese_tail (edge entry, edge exit, /* Record blocks outside the region that are dominated by something inside. */ - doms = get_dominated_by_region (CDI_DOMINATORS, region, n_region); + auto_vec doms = get_dominated_by_region (CDI_DOMINATORS, region, + n_region); total_count = exit->src->count; exit_count = exit->count (); @@ -6785,7 +6783,6 @@ gimple_duplicate_sese_tail (edge entry, edge exit, /* Anything that is outside of the region, but was dominated by something inside needs to update dominance info. */ iterate_fix_dominators (CDI_DOMINATORS, doms, false); - doms.release (); /* Update the SSA web. */ update_ssa (TODO_update_ssa); @@ -7567,7 +7564,7 @@ basic_block move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, basic_block exit_bb, tree orig_block) { - vec bbs, dom_bbs; + vec bbs; basic_block dom_entry = get_immediate_dominator (CDI_DOMINATORS, entry_bb); basic_block after, bb, *entry_pred, *exit_succ, abb; struct function *saved_cfun = cfun; @@ -7599,9 +7596,9 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, /* The blocks that used to be dominated by something in BBS will now be dominated by the new block. */ - dom_bbs = get_dominated_by_region (CDI_DOMINATORS, - bbs.address (), - bbs.length ()); + auto_vec dom_bbs = get_dominated_by_region (CDI_DOMINATORS, + bbs.address (), + bbs.length ()); /* Detach ENTRY_BB and EXIT_BB from CFUN->CFG. We need to remember the predecessor edges to ENTRY_BB and the successor edges to @@ -7937,7 +7934,6 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, set_immediate_dominator (CDI_DOMINATORS, bb, dom_entry); FOR_EACH_VEC_ELT (dom_bbs, i, abb) set_immediate_dominator (CDI_DOMINATORS, abb, bb); - dom_bbs.release (); if (exit_bb) { From patchwork Tue Jun 15 05:59:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 1491991 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 4G3yR50ZQVz9sTD for ; Tue, 15 Jun 2021 16:02:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9579E3987C02 for ; Tue, 15 Jun 2021 06:02:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from paperclip.tbsaunde.org (unknown [IPv6:2600:3c03::f03c:91ff:fe6e:c625]) by sourceware.org (Postfix) with ESMTP id C3DF039878E3 for ; Tue, 15 Jun 2021 06:00:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C3DF039878E3 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 9DA72C085; Tue, 15 Jun 2021 06:00:00 +0000 (UTC) From: Trevor Saunders To: gcc-patches@gcc.gnu.org Subject: [PATCH 6/6] return auto_vec from more dominance functions Date: Tue, 15 Jun 2021 01:59:22 -0400 Message-Id: <20210615055922.27205-6-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=-9.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_SBL_CSS, 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 vector gets cleaned up by the caller when appropriate. Signed-off-by: Trevor Saunders bootstrapped and regtested on x86_64-linux-gnu, ok? gcc/ChangeLog: * dominance.c (get_dominated_to_depth): Return auto_vec. * dominance.h (get_dominated_to_depth): Likewise. (get_all_dominated_blocks): Likewise. * cfgcleanup.c (delete_unreachable_blocks): Adjust. * gcse.c (hoist_code): Likewise. * tree-cfg.c (remove_edge_and_dominated_blocks): Likewise. * tree-parloops.c (oacc_entry_exit_ok): Likewise. * tree-ssa-dce.c (eliminate_unnecessary_stmts): Likewise. * tree-ssa-phiprop.c (pass_phiprop::execute): Likewise. --- gcc/cfgcleanup.c | 4 +--- gcc/dominance.c | 6 +++--- gcc/dominance.h | 8 ++++---- gcc/gcse.c | 13 +++++-------- gcc/tree-cfg.c | 3 +-- gcc/tree-parloops.c | 3 +-- gcc/tree-ssa-dce.c | 3 +-- gcc/tree-ssa-phiprop.c | 7 +++---- 8 files changed, 19 insertions(+), 28 deletions(-) diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 17edc4f37ad..7b1e1ba6e80 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -3027,7 +3027,7 @@ delete_unreachable_blocks (void) delete_basic_block (b); else { - vec h + auto_vec h = get_all_dominated_blocks (CDI_DOMINATORS, b); while (h.length ()) @@ -3040,8 +3040,6 @@ delete_unreachable_blocks (void) delete_basic_block (b); } - - h.release (); } changed = true; diff --git a/gcc/dominance.c b/gcc/dominance.c index 4943102ff1d..6a262ce8283 100644 --- a/gcc/dominance.c +++ b/gcc/dominance.c @@ -933,10 +933,10 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region, produce a vector containing all dominated blocks. The vector will be sorted in preorder. */ -vec +auto_vec get_dominated_to_depth (enum cdi_direction dir, basic_block bb, int depth) { - vec bbs = vNULL; + auto_vec bbs; unsigned i; unsigned next_level_start; @@ -965,7 +965,7 @@ get_dominated_to_depth (enum cdi_direction dir, basic_block bb, int depth) /* Returns the list of basic blocks including BB dominated by BB, in the direction DIR. The vector will be sorted in preorder. */ -vec +auto_vec get_all_dominated_blocks (enum cdi_direction dir, basic_block bb) { return get_dominated_to_depth (dir, bb, 0); diff --git a/gcc/dominance.h b/gcc/dominance.h index c74ad297c6a..1a8c248ee98 100644 --- a/gcc/dominance.h +++ b/gcc/dominance.h @@ -50,10 +50,10 @@ extern auto_vec get_dominated_by (enum cdi_direction, basic_block); extern auto_vec get_dominated_by_region (enum cdi_direction, basic_block *, unsigned); -extern vec get_dominated_to_depth (enum cdi_direction, - basic_block, int); -extern vec get_all_dominated_blocks (enum cdi_direction, - basic_block); +extern auto_vec get_dominated_to_depth (enum cdi_direction, + basic_block, int); +extern auto_vec get_all_dominated_blocks (enum cdi_direction, + basic_block); extern void redirect_immediate_dominators (enum cdi_direction, basic_block, basic_block); extern basic_block nearest_common_dominator (enum cdi_direction, diff --git a/gcc/gcse.c b/gcc/gcse.c index 9114f30705e..ecf7e51aac5 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -3050,9 +3050,7 @@ static int hoist_code (void) { basic_block bb, dominated; - vec dom_tree_walk; unsigned int dom_tree_walk_index; - vec domby; unsigned int i, j, k; struct gcse_expr **index_map; struct gcse_expr *expr; @@ -3106,15 +3104,16 @@ hoist_code (void) if (flag_ira_hoist_pressure) hoisted_bbs = BITMAP_ALLOC (NULL); - dom_tree_walk = get_all_dominated_blocks (CDI_DOMINATORS, - ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb); + auto_vec dom_tree_walk + = get_all_dominated_blocks (CDI_DOMINATORS, + ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb); /* Walk over each basic block looking for potentially hoistable expressions, nothing gets hoisted from the entry block. */ FOR_EACH_VEC_ELT (dom_tree_walk, dom_tree_walk_index, bb) { - domby = get_dominated_to_depth (CDI_DOMINATORS, bb, - param_max_hoist_depth); + auto_vec domby + = get_dominated_to_depth (CDI_DOMINATORS, bb, param_max_hoist_depth); if (domby.length () == 0) continue; @@ -3315,10 +3314,8 @@ hoist_code (void) bitmap_clear (from_bbs); } } - domby.release (); } - dom_tree_walk.release (); BITMAP_FREE (from_bbs); if (flag_ira_hoist_pressure) BITMAP_FREE (hoisted_bbs); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index c9403deed19..4c32f83257f 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -8683,7 +8683,6 @@ gimple_flow_call_edges_add (sbitmap blocks) void remove_edge_and_dominated_blocks (edge e) { - vec bbs_to_remove = vNULL; vec bbs_to_fix_dom = vNULL; edge f; edge_iterator ei; @@ -8734,6 +8733,7 @@ remove_edge_and_dominated_blocks (edge e) } auto_bitmap df, df_idom; + auto_vec bbs_to_remove; if (none_removed) bitmap_set_bit (df_idom, get_immediate_dominator (CDI_DOMINATORS, e->dest)->index); @@ -8800,7 +8800,6 @@ remove_edge_and_dominated_blocks (edge e) iterate_fix_dominators (CDI_DOMINATORS, bbs_to_fix_dom, true); - bbs_to_remove.release (); bbs_to_fix_dom.release (); } diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index deff2d5e08b..fe1baef32a7 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -3949,7 +3949,7 @@ oacc_entry_exit_ok (class loop *loop, reduction_info_table_type *reduction_list) { basic_block *loop_bbs = get_loop_body_in_dom_order (loop); - vec region_bbs + auto_vec region_bbs = get_all_dominated_blocks (CDI_DOMINATORS, ENTRY_BLOCK_PTR_FOR_FN (cfun)); bitmap in_loop_bbs = BITMAP_ALLOC (NULL); @@ -3972,7 +3972,6 @@ oacc_entry_exit_ok (class loop *loop, } } - region_bbs.release (); free (loop_bbs); BITMAP_FREE (in_loop_bbs); diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index def6ae69e24..e2d3b63a30c 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1275,7 +1275,6 @@ eliminate_unnecessary_stmts (void) gimple_stmt_iterator gsi, psi; gimple *stmt; tree call; - vec h; auto_vec to_remove_edges; if (dump_file && (dump_flags & TDF_DETAILS)) @@ -1306,6 +1305,7 @@ eliminate_unnecessary_stmts (void) as desired. */ gcc_assert (dom_info_available_p (CDI_DOMINATORS)); + auto_vec h; h = get_all_dominated_blocks (CDI_DOMINATORS, single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))); @@ -1460,7 +1460,6 @@ eliminate_unnecessary_stmts (void) something_changed |= remove_dead_phis (bb); } - h.release (); /* Since we don't track liveness of virtual PHI nodes, it is possible that we rendered some PHI nodes unreachable while they are still in use. diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index 64d6eda5f6c..78b0461c839 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -484,7 +484,6 @@ public: unsigned int pass_phiprop::execute (function *fun) { - vec bbs; struct phiprop_d *phivn; bool did_something = false; basic_block bb; @@ -499,8 +498,9 @@ pass_phiprop::execute (function *fun) phivn = XCNEWVEC (struct phiprop_d, n); /* Walk the dominator tree in preorder. */ - bbs = get_all_dominated_blocks (CDI_DOMINATORS, - single_succ (ENTRY_BLOCK_PTR_FOR_FN (fun))); + auto_vec bbs + = get_all_dominated_blocks (CDI_DOMINATORS, + single_succ (ENTRY_BLOCK_PTR_FOR_FN (fun))); FOR_EACH_VEC_ELT (bbs, i, bb) { /* Since we're going to move dereferences across predecessor @@ -514,7 +514,6 @@ pass_phiprop::execute (function *fun) if (did_something) gsi_commit_edge_inserts (); - bbs.release (); free (phivn); free_dominance_info (CDI_POST_DOMINATORS);