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) {