On Sun, Jul 24, 2016 at 1:44 PM,  <tbsaunde+...@tbsaunde.org> wrote:
> From: Trevor Saunders <tbsaunde+...@tbsaunde.org>
>
> gcc/ChangeLog:
>
> 2016-07-24  Trevor Saunders  <tbsaunde+...@tbsaunde.org>
>
>         * tree-ssa-structalias.c (struct topo_info): Add constructor,
>         and change types of members to auto_vec and auto_sbitmap.
>         (init_topo_info): Remove.
>         (topo_info::topo_info): New constructor.
>         (solve_graph): Adjust.
> ---
>  gcc/tree-ssa-structalias.c | 31 ++++++++-----------------------
>  1 file changed, 8 insertions(+), 23 deletions(-)
>
> diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
> index 5e3c7d0..94d81ed1 100644
> --- a/gcc/tree-ssa-structalias.c
> +++ b/gcc/tree-ssa-structalias.c
> @@ -1536,36 +1536,21 @@ unify_nodes (constraint_graph_t graph, unsigned int 
> to, unsigned int from,
>
>  struct topo_info
>  {
> +  topo_info ();
> +
>    /* sbitmap of visited nodes.  */
> -  sbitmap visited;
> +  auto_sbitmap visited;
>    /* Array that stores the topological order of the graph, *in
>       reverse*.  */
> -  vec<unsigned> topo_order;
> +  auto_vec<unsigned> topo_order;
>  };
>
>
>  /* Initialize and return a topological info structure.  */
>
> -static struct topo_info *
> -init_topo_info (void)
> -{
> -  size_t size = graph->size;
> -  struct topo_info *ti = XNEW (struct topo_info);
> -  ti->visited = sbitmap_alloc (size);
> -  bitmap_clear (ti->visited);
> -  ti->topo_order.create (1);
> -  return ti;
> -}
> -
> -
> -/* Free the topological sort info pointed to by TI.  */
> -
> -static void
> -free_topo_info (struct topo_info *ti)
> +topo_info::topo_info () : visited (graph->size), topo_order (1)
>  {
> -  sbitmap_free (ti->visited);
> -  ti->topo_order.release ();
> -  free (ti);
> +  bitmap_clear (visited);
>  }
>
>  /* Visit the graph in topological order, and store the order in the
> @@ -2679,7 +2664,7 @@ solve_graph (constraint_graph_t graph)
>    while (!bitmap_empty_p (changed))
>      {
>        unsigned int i;
> -      struct topo_info *ti = init_topo_info ();
> +      topo_info *ti = new topo_info ();

I think it would be better to save the repeated allocations and instead just
clear the bitmap and the vector here.  Your patch makes this more
difficult.

Richard.

>        stats.iterations++;
>
>        bitmap_obstack_initialize (&iteration_obstack);
> @@ -2797,7 +2782,7 @@ solve_graph (constraint_graph_t graph)
>                 }
>             }
>         }
> -      free_topo_info (ti);
> +      delete ti;
>        bitmap_obstack_release (&iteration_obstack);
>      }
>
> --
> 2.9.0
>

Reply via email to