On Wed, 20 Nov 2019, Jan Hubicka wrote:

> Hi,
> another common (ab)use of malloc/free is the DEF worklist and stack
> used in streaming out.  Since most of SCCs are small, we could easily
> use stack for them in majority of time.
> 
> Bootstrapped/regtested x86_64-linux, OK?

OK.

>       * lto-streamer-out.c (DFS::sccstack): Turn into auto-vec;
>       preallocate for 32 entries.
>       (DFS::worklist_vec): Likewise.
>       (DFS::DFS): Do not initialize sccstack and worklist.
>       (DFS::~DFS): Do not release sccstack.
> 
> Index: lto-streamer-out.c
> ===================================================================
> --- lto-streamer-out.c        (revision 278464)
> +++ lto-streamer-out.c        (working copy)
> @@ -514,7 +514,7 @@ public:
>      tree t;
>      hashval_t hash;
>    };
> -  vec<scc_entry> sccstack;
> +  auto_vec<scc_entry, 32> sccstack;
>  
>  private:
>    struct sccs
> @@ -544,7 +544,7 @@ private:
>           bool ref_p, bool this_ref_p);
>  
>    hash_map<tree, sccs *> sccstate;
> -  vec<worklist> worklist_vec;
> +  auto_vec<worklist, 32> worklist_vec;
>    struct obstack sccstate_obstack;
>  };
>  
> @@ -558,9 +558,7 @@ DFS::DFS (struct output_block *ob, tree
>         bool single_p)
>  {
>    unsigned int next_dfs_num = 1;
> -  sccstack.create (0);
>    gcc_obstack_init (&sccstate_obstack);
> -  worklist_vec = vNULL;
>    DFS_write_tree (ob, NULL, expr, ref_p, this_ref_p);
>    while (!worklist_vec.is_empty ())
>      {
> @@ -735,12 +733,10 @@ DFS::DFS (struct output_block *ob, tree
>       from_state->low = MIN (cstate->dfsnum, from_state->low);
>        worklist_vec.pop ();
>      }
> -  worklist_vec.release ();
>  }
>  
>  DFS::~DFS ()
>  {
> -  sccstack.release ();
>    obstack_free (&sccstate_obstack, NULL);
>  }
>  
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

Reply via email to