From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id 115963858028; Wed, 15 Feb 2023 10:14:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 115963858028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676456071; bh=gHVc8PnZNEF+MR3WXeeb9GBbl/4WbNva4It26UIIe7s=; h=From:To:Subject:Date:From; b=wX4ArgyeSvldpz9lcJ0T9Yd0V6CtqkFpKWJihcQ4xwdTLHe+kLUf8jOoCYHiiOnOm 1uuc2kHAEOKCJ5jKxnY+3CNNyMhDadHILsyHeAkf66+XnblD8R+ZwPZU7x28cM8vpU s99SRsdJ4hlvICE3tTtumkDMCKorP3fhdIURK9Oc= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Filip Kastl To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/pheeck/heads/sccp)] added freeing vector memory X-Act-Checkin: gcc X-Git-Author: Filip Kastl X-Git-Refname: refs/users/pheeck/heads/sccp X-Git-Oldrev: 24ad163a226c2d525e71cef9b1bf7f3f7a6d8401 X-Git-Newrev: e86926f6099b4ecc18f93d7c26e88f200a5d69b1 Message-Id: <20230215101431.115963858028@sourceware.org> Date: Wed, 15 Feb 2023 10:14:31 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e86926f6099b4ecc18f93d7c26e88f200a5d69b1 commit e86926f6099b4ecc18f93d7c26e88f200a5d69b1 Author: Filip Kastl Date: Tue Sep 6 11:42:08 2022 +0200 added freeing vector memory Diff: --- gcc/sccp.cc | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/gcc/sccp.cc b/gcc/sccp.cc index 8574d424b66..c202c9f76e5 100644 --- a/gcc/sccp.cc +++ b/gcc/sccp.cc @@ -145,10 +145,10 @@ debug_phis (void) // DEBUG /* Return vector of all PHI functions from all basic blocks. */ -static vec +static auto_vec get_all_phis (void) { - vec result = vNULL; + auto_vec result; basic_block bb; FOR_EACH_BB_FN (bb, cfun) @@ -164,10 +164,10 @@ get_all_phis (void) return result; } -static vec -tarjan_phis_to_vertices (vec phis) +static auto_vec +tarjan_phis_to_vertices (auto_vec &phis) { - vec result = vNULL; + auto_vec result; for (gphi *phi : phis) { vertex v; @@ -181,15 +181,15 @@ tarjan_phis_to_vertices (vec phis) return result; } -static vec> -tarjan_compute_sccs (vec phis) +static auto_vec> +tarjan_compute_sccs (auto_vec &phis) { - vec> sccs = vNULL; - vec worklist = vNULL; - vec stack = vNULL; + auto_vec> sccs; + auto_vec worklist; + auto_vec stack; unsigned curr_index = 0; - vec vs = tarjan_phis_to_vertices (phis); + auto_vec vs = tarjan_phis_to_vertices (phis); /* Assign phinums and set PHI functions' 'using' flag. */ unsigned i; @@ -297,7 +297,7 @@ tarjan_compute_sccs (vec phis) /* If this is the root of an scc, pop it from stack. */ if (vs[i].lowlink == vs[i].index) { - vec scc = vNULL; + auto_vec scc; unsigned j; do @@ -330,7 +330,7 @@ tarjan_compute_sccs (vec phis) } static void -replace_scc_by_value (vec scc, tree v) +replace_scc_by_value (vec &scc, tree v) { for (gphi *phi : scc) { @@ -381,16 +381,16 @@ remove_zero_uses_phis () } static void -remove_redundant_phis (vec phis) +remove_redundant_phis (auto_vec &phis) { - vec> worklist = vNULL; + auto_vec> worklist; worklist = tarjan_compute_sccs (phis); while (!worklist.is_empty ()) { vec scc = worklist.pop (); - vec inner = vNULL; + auto_vec inner; hash_set outer_ops; for (gphi *phi : scc) @@ -448,12 +448,14 @@ remove_redundant_phis (vec phis) else if (outer_ops.elements () > 1) { /* Add inner sccs to worklist. */ - vec> inner_sccs = tarjan_compute_sccs (inner); + auto_vec> inner_sccs = tarjan_compute_sccs (inner); for (vec inner_scc : inner_sccs) { worklist.safe_push (inner_scc); } } + + scc.release(); } remove_zero_uses_phis (); @@ -494,7 +496,8 @@ pass_sccp::execute (function *) //debug_phis (); // DEBUG init_sccp (); - remove_redundant_phis (get_all_phis ()); + auto_vec phis = get_all_phis (); + remove_redundant_phis (phis); finalize_sccp (); /*