public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/pheeck/heads/sccp)] added freeing vector memory
@ 2022-09-06  9:42 Filip Kastl
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2022-09-06  9:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bbbbeaac9644776f06f5b03c366567c21b7b7288

commit bbbbeaac9644776f06f5b03c366567c21b7b7288
Author: Filip Kastl <filip.kastl@gmail.com>
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<gphi *>
+static auto_vec<gphi *>
 get_all_phis (void)
 {
-  vec<gphi *> result = vNULL;
+  auto_vec<gphi *> result;
 
   basic_block bb;
   FOR_EACH_BB_FN (bb, cfun)
@@ -164,10 +164,10 @@ get_all_phis (void)
   return result;
 }
 
-static vec<vertex>
-tarjan_phis_to_vertices (vec<gphi *> phis)
+static auto_vec<vertex>
+tarjan_phis_to_vertices (auto_vec<gphi *> &phis)
 {
-  vec<vertex> result = vNULL;
+  auto_vec<vertex> result;
   for (gphi *phi : phis)
     {
       vertex v;
@@ -181,15 +181,15 @@ tarjan_phis_to_vertices (vec<gphi *> phis)
   return result;
 }
 
-static vec<vec<gphi *>>
-tarjan_compute_sccs (vec<gphi *> phis)
+static auto_vec<vec<gphi *>>
+tarjan_compute_sccs (auto_vec<gphi *> &phis)
 {
-  vec<vec<gphi *>> sccs = vNULL;
-  vec<unsigned> worklist = vNULL;
-  vec<unsigned> stack = vNULL;
+  auto_vec<vec<gphi *>> sccs;
+  auto_vec<unsigned> worklist;
+  auto_vec<unsigned> stack;
   unsigned curr_index = 0;
 
-  vec<vertex> vs = tarjan_phis_to_vertices (phis);
+  auto_vec<vertex> vs = tarjan_phis_to_vertices (phis);
 
   /* Assign phinums and set PHI functions' 'using' flag.  */
   unsigned i;
@@ -297,7 +297,7 @@ tarjan_compute_sccs (vec<gphi *> phis)
 	  /* If this is the root of an scc, pop it from stack.  */
 	  if (vs[i].lowlink == vs[i].index)
 	    {
-	      vec<gphi *> scc = vNULL;
+	      auto_vec<gphi *> scc;
 
 	      unsigned j;
 	      do
@@ -330,7 +330,7 @@ tarjan_compute_sccs (vec<gphi *> phis)
 }
 
 static void
-replace_scc_by_value (vec<gphi *> scc, tree v)
+replace_scc_by_value (vec<gphi *> &scc, tree v)
 {
   for (gphi *phi : scc)
     {
@@ -381,16 +381,16 @@ remove_zero_uses_phis ()
 }
 
 static void
-remove_redundant_phis (vec<gphi *> phis)
+remove_redundant_phis (auto_vec<gphi *> &phis)
 {
-  vec<vec<gphi *>> worklist = vNULL;
+  auto_vec<vec<gphi *>> worklist;
   worklist = tarjan_compute_sccs (phis);
 
   while (!worklist.is_empty ())
     {
       vec<gphi *> scc = worklist.pop ();
 
-      vec<gphi *> inner = vNULL;
+      auto_vec<gphi *> inner;
       hash_set<tree> outer_ops;
 
       for (gphi *phi : scc)
@@ -448,12 +448,14 @@ remove_redundant_phis (vec<gphi *> phis)
       else if (outer_ops.elements () > 1)
 	{
 	  /* Add inner sccs to worklist.  */
-	  vec<vec<gphi *>> inner_sccs = tarjan_compute_sccs (inner);
+	  auto_vec<vec<gphi *>> inner_sccs = tarjan_compute_sccs (inner);
 	  for (vec<gphi *> 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<gphi *> phis = get_all_phis ();
+  remove_redundant_phis (phis);
   finalize_sccp ();
 
   /*

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/pheeck/heads/sccp)] added freeing vector memory
@ 2023-02-15 10:14 Filip Kastl
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2023-02-15 10:14 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e86926f6099b4ecc18f93d7c26e88f200a5d69b1

commit e86926f6099b4ecc18f93d7c26e88f200a5d69b1
Author: Filip Kastl <filip.kastl@gmail.com>
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<gphi *>
+static auto_vec<gphi *>
 get_all_phis (void)
 {
-  vec<gphi *> result = vNULL;
+  auto_vec<gphi *> result;
 
   basic_block bb;
   FOR_EACH_BB_FN (bb, cfun)
@@ -164,10 +164,10 @@ get_all_phis (void)
   return result;
 }
 
-static vec<vertex>
-tarjan_phis_to_vertices (vec<gphi *> phis)
+static auto_vec<vertex>
+tarjan_phis_to_vertices (auto_vec<gphi *> &phis)
 {
-  vec<vertex> result = vNULL;
+  auto_vec<vertex> result;
   for (gphi *phi : phis)
     {
       vertex v;
@@ -181,15 +181,15 @@ tarjan_phis_to_vertices (vec<gphi *> phis)
   return result;
 }
 
-static vec<vec<gphi *>>
-tarjan_compute_sccs (vec<gphi *> phis)
+static auto_vec<vec<gphi *>>
+tarjan_compute_sccs (auto_vec<gphi *> &phis)
 {
-  vec<vec<gphi *>> sccs = vNULL;
-  vec<unsigned> worklist = vNULL;
-  vec<unsigned> stack = vNULL;
+  auto_vec<vec<gphi *>> sccs;
+  auto_vec<unsigned> worklist;
+  auto_vec<unsigned> stack;
   unsigned curr_index = 0;
 
-  vec<vertex> vs = tarjan_phis_to_vertices (phis);
+  auto_vec<vertex> vs = tarjan_phis_to_vertices (phis);
 
   /* Assign phinums and set PHI functions' 'using' flag.  */
   unsigned i;
@@ -297,7 +297,7 @@ tarjan_compute_sccs (vec<gphi *> phis)
 	  /* If this is the root of an scc, pop it from stack.  */
 	  if (vs[i].lowlink == vs[i].index)
 	    {
-	      vec<gphi *> scc = vNULL;
+	      auto_vec<gphi *> scc;
 
 	      unsigned j;
 	      do
@@ -330,7 +330,7 @@ tarjan_compute_sccs (vec<gphi *> phis)
 }
 
 static void
-replace_scc_by_value (vec<gphi *> scc, tree v)
+replace_scc_by_value (vec<gphi *> &scc, tree v)
 {
   for (gphi *phi : scc)
     {
@@ -381,16 +381,16 @@ remove_zero_uses_phis ()
 }
 
 static void
-remove_redundant_phis (vec<gphi *> phis)
+remove_redundant_phis (auto_vec<gphi *> &phis)
 {
-  vec<vec<gphi *>> worklist = vNULL;
+  auto_vec<vec<gphi *>> worklist;
   worklist = tarjan_compute_sccs (phis);
 
   while (!worklist.is_empty ())
     {
       vec<gphi *> scc = worklist.pop ();
 
-      vec<gphi *> inner = vNULL;
+      auto_vec<gphi *> inner;
       hash_set<tree> outer_ops;
 
       for (gphi *phi : scc)
@@ -448,12 +448,14 @@ remove_redundant_phis (vec<gphi *> phis)
       else if (outer_ops.elements () > 1)
 	{
 	  /* Add inner sccs to worklist.  */
-	  vec<vec<gphi *>> inner_sccs = tarjan_compute_sccs (inner);
+	  auto_vec<vec<gphi *>> inner_sccs = tarjan_compute_sccs (inner);
 	  for (vec<gphi *> 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<gphi *> phis = get_all_phis ();
+  remove_redundant_phis (phis);
   finalize_sccp ();
 
   /*

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-15 10:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06  9:42 [gcc(refs/users/pheeck/heads/sccp)] added freeing vector memory Filip Kastl
2023-02-15 10:14 Filip Kastl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).