Re: [PATCH] add hash_set

2014-08-04 Thread Jeff Law

On 08/04/14 11:15, Trevor Saunders wrote:

On Sat, Aug 02, 2014 at 03:44:17PM -0700, Andrew Pinski wrote:

On Tue, Jul 29, 2014 at 5:50 AM,  tsaund...@mozilla.com wrote:

From: Trevor Saunders tsaund...@mozilla.com

Hi,

this adds a hash_set wrapper around hash_table, and then replaces usage of 
pointer_set with it.

bootstrapped +regtested on x86_64-unknown-linux-gnu, ok?

Trev

ada/

 * gcc-interface/trans.c: Use hash_set instead of pointer_set.

c-family/

 * c-gimplify.c: Use hash_set instead of pointer_set.

c/

 * c-decl.c: Use hash_set instead of pointer_set.

cp/

 * class.c, cp-gimplify.c, cp-tree.h, decl.c, decl2.c, error.c,
 method.c, name-lookup.c, pt.c, semantics.c, tree.c: Use hash_set
 instead of pointer_set.

fortran/

 * openmp.c, trans-decl.c: Use hash_set instead of pointer_set.

gcc/

 * hash-set.h: new File.
 * cfgexpand.c, cfgloop.c, cgraph.c, cgraphbuild.c, cgraphunit.c,
 cprop.c, cse.c, gimple-walk.c, gimple-walk.h, gimplify.c, godump.c,
 ipa-devirt.c, ipa-pure-const.c, ipa-visibility.c, ipa.c, lto-cgraph.c,
 lto-streamer-out.c, stmt.c, tree-cfg.c, tree-core.h, tree-eh.c,
 tree-inline.c, tree-inline.h, tree-nested.c, tree-pretty-print.c,
 tree-ssa-loop-niter.c, tree-ssa-phiopt.c, tree-ssa-threadedge.c,
 tree-ssa-uninit.c, tree.c, tree.h, value-prof.c, varasm.c,
 varpool.c: Use hash_set instead of pointer_set.



This changelog is less than useful and really does not follow the
GCC/GNU coding style.  Please expand and place all functions which are


I'm pretty sure its written somewhere that format is ok, and there's
precedent for it.  Note the update all callers rule could also be used
to just write
Note we discussed this at Cauldron and there was a general consensus 
that the update all callers style was reasonable.


FWIW, that's actually be approved for use in GCC for a very long time. 
We've allowed using that style, without having to list each function 
changed, since the late 90s.


jeff




Re: [PATCH] add hash_set

2014-08-04 Thread Mike Stump
On Aug 4, 2014, at 10:46 AM, Trevor Saunders tsaund...@mozilla.com wrote:
 
 I had a conflict which is why I noticed this issue in the first place. And I 
 was using git merge :). 
 
 I bet git log or blaim would get you better data faster.

So, git merging I would recommend:

[merge]
conflictstyle = diff3
[rerere]
enabled = 1

if you don’t already.  I think diff3 should be the default it is so handy.

Re: [PATCH] add hash_set

2014-08-02 Thread Andrew Pinski
On Tue, Jul 29, 2014 at 5:50 AM,  tsaund...@mozilla.com wrote:
 From: Trevor Saunders tsaund...@mozilla.com

 Hi,

 this adds a hash_set wrapper around hash_table, and then replaces usage of 
 pointer_set with it.

 bootstrapped +regtested on x86_64-unknown-linux-gnu, ok?

 Trev

 ada/

 * gcc-interface/trans.c: Use hash_set instead of pointer_set.

 c-family/

 * c-gimplify.c: Use hash_set instead of pointer_set.

 c/

 * c-decl.c: Use hash_set instead of pointer_set.

 cp/

 * class.c, cp-gimplify.c, cp-tree.h, decl.c, decl2.c, error.c,
 method.c, name-lookup.c, pt.c, semantics.c, tree.c: Use hash_set
 instead of pointer_set.

 fortran/

 * openmp.c, trans-decl.c: Use hash_set instead of pointer_set.

 gcc/

 * hash-set.h: new File.
 * cfgexpand.c, cfgloop.c, cgraph.c, cgraphbuild.c, cgraphunit.c,
 cprop.c, cse.c, gimple-walk.c, gimple-walk.h, gimplify.c, godump.c,
 ipa-devirt.c, ipa-pure-const.c, ipa-visibility.c, ipa.c, lto-cgraph.c,
 lto-streamer-out.c, stmt.c, tree-cfg.c, tree-core.h, tree-eh.c,
 tree-inline.c, tree-inline.h, tree-nested.c, tree-pretty-print.c,
 tree-ssa-loop-niter.c, tree-ssa-phiopt.c, tree-ssa-threadedge.c,
 tree-ssa-uninit.c, tree.c, tree.h, value-prof.c, varasm.c,
 varpool.c: Use hash_set instead of pointer_set.


This changelog is less than useful and really does not follow the
GCC/GNU coding style.  Please expand and place all functions which are
changed in it.  I use ChangeLog entries when merging in code to see
which of the merged code I need to pick up.

Thanks,
Andrew Pinski




 lto/

 * lto-partition.c, lto-partition.h: Use hash_set instead of
 pointer_set.
 diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
 index f42ac7f..6961838 100644
 --- a/gcc/ada/gcc-interface/trans.c
 +++ b/gcc/ada/gcc-interface/trans.c
 @@ -36,7 +36,7 @@
  #include output.h
  #include libfuncs.h  /* For set_stack_check_libfunc.  */
  #include tree-iterator.h
 -#include pointer-set.h
 +#include hash-set.h
  #include gimple-expr.h
  #include gimplify.h
  #include bitmap.h
 @@ -3054,7 +3054,7 @@ struct nrv_data
bitmap nrv;
tree result;
Node_Id gnat_ret;
 -  struct pointer_set_t *visited;
 +  hash_settree *visited;
  };

  /* Return true if T is a Named Return Value.  */
 @@ -3188,7 +3188,7 @@ finalize_nrv_r (tree *tp, int *walk_subtrees, void 
 *data)
/* Avoid walking into the same tree more than once.  Unfortunately, we
   can't just use walk_tree_without_duplicates because it would only
   call us for the first occurrence of NRVs in the function body.  */
 -  if (pointer_set_insert (dp-visited, *tp))
 +  if (dp-visited-add (*tp))
  *walk_subtrees = 0;

return NULL_TREE;
 @@ -3328,7 +3328,7 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void 
 *data)
/* Avoid walking into the same tree more than once.  Unfortunately, we
   can't just use walk_tree_without_duplicates because it would only
   call us for the first occurrence of NRVs in the function body.  */
 -  if (pointer_set_insert (dp-visited, *tp))
 +  if (dp-visited-add (*tp))
  *walk_subtrees = 0;

return NULL_TREE;
 @@ -3376,13 +3376,13 @@ finalize_nrv (tree fndecl, bitmap nrv, vectree, 
 va_gc *other, Node_Id gnat_ret
data.nrv = nrv;
data.result = DECL_RESULT (fndecl);
data.gnat_ret = gnat_ret;
 -  data.visited = pointer_set_create ();
 +  data.visited = new hash_settree;
if (TYPE_RETURN_UNCONSTRAINED_P (TREE_TYPE (fndecl)))
  func = finalize_nrv_unc_r;
else
  func = finalize_nrv_r;
walk_tree (DECL_SAVED_TREE (fndecl), func, data, NULL);
 -  pointer_set_destroy (data.visited);
 +  delete data.visited;
  }

  /* Return true if RET_VAL can be used as a Named Return Value for the
 diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
 index 2b5ce5b..4898217 100644
 --- a/gcc/c-family/c-gimplify.c
 +++ b/gcc/c-family/c-gimplify.c
 @@ -74,7 +74,7 @@ along with GCC; see the file COPYING3.  If not see
  static tree
  ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
  {
 -  struct pointer_set_t *pset = (struct pointer_set_t *) data;
 +  hash_settree *pset = (hash_settree *) data;

/* Since walk_tree doesn't call the callback function on the decls
   in BIND_EXPR_VARS, we have to walk them manually.  */
 @@ -116,10 +116,9 @@ c_genericize (tree fndecl)

if (flag_sanitize  SANITIZE_BOUNDS)
  {
 -  struct pointer_set_t *pset = pointer_set_create ();
 -  walk_tree (DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, pset,
 -pset);
 -  pointer_set_destroy (pset);
 +  hash_settree pset;
 +  walk_tree (DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, pset,
 +pset);
  }

/* Dump the C-specific tree IR.  */
 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
 index 2a4b439..050ddff 100644
 --- 

Re: [PATCH] add hash_set

2014-07-30 Thread Richard Biener
On Tue, Jul 29, 2014 at 2:50 PM,  tsaund...@mozilla.com wrote:
 From: Trevor Saunders tsaund...@mozilla.com

 Hi,

 this adds a hash_set wrapper around hash_table, and then replaces usage of 
 pointer_set with it.

 bootstrapped +regtested on x86_64-unknown-linux-gnu, ok?

Ok.

Thanks,
Richard.

 Trev

 ada/

 * gcc-interface/trans.c: Use hash_set instead of pointer_set.

 c-family/

 * c-gimplify.c: Use hash_set instead of pointer_set.

 c/

 * c-decl.c: Use hash_set instead of pointer_set.

 cp/

 * class.c, cp-gimplify.c, cp-tree.h, decl.c, decl2.c, error.c,
 method.c, name-lookup.c, pt.c, semantics.c, tree.c: Use hash_set
 instead of pointer_set.

 fortran/

 * openmp.c, trans-decl.c: Use hash_set instead of pointer_set.

 gcc/

 * hash-set.h: new File.
 * cfgexpand.c, cfgloop.c, cgraph.c, cgraphbuild.c, cgraphunit.c,
 cprop.c, cse.c, gimple-walk.c, gimple-walk.h, gimplify.c, godump.c,
 ipa-devirt.c, ipa-pure-const.c, ipa-visibility.c, ipa.c, lto-cgraph.c,
 lto-streamer-out.c, stmt.c, tree-cfg.c, tree-core.h, tree-eh.c,
 tree-inline.c, tree-inline.h, tree-nested.c, tree-pretty-print.c,
 tree-ssa-loop-niter.c, tree-ssa-phiopt.c, tree-ssa-threadedge.c,
 tree-ssa-uninit.c, tree.c, tree.h, value-prof.c, varasm.c,
 varpool.c: Use hash_set instead of pointer_set.

 lto/

 * lto-partition.c, lto-partition.h: Use hash_set instead of
 pointer_set.
 diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
 index f42ac7f..6961838 100644
 --- a/gcc/ada/gcc-interface/trans.c
 +++ b/gcc/ada/gcc-interface/trans.c
 @@ -36,7 +36,7 @@
  #include output.h
  #include libfuncs.h  /* For set_stack_check_libfunc.  */
  #include tree-iterator.h
 -#include pointer-set.h
 +#include hash-set.h
  #include gimple-expr.h
  #include gimplify.h
  #include bitmap.h
 @@ -3054,7 +3054,7 @@ struct nrv_data
bitmap nrv;
tree result;
Node_Id gnat_ret;
 -  struct pointer_set_t *visited;
 +  hash_settree *visited;
  };

  /* Return true if T is a Named Return Value.  */
 @@ -3188,7 +3188,7 @@ finalize_nrv_r (tree *tp, int *walk_subtrees, void 
 *data)
/* Avoid walking into the same tree more than once.  Unfortunately, we
   can't just use walk_tree_without_duplicates because it would only
   call us for the first occurrence of NRVs in the function body.  */
 -  if (pointer_set_insert (dp-visited, *tp))
 +  if (dp-visited-add (*tp))
  *walk_subtrees = 0;

return NULL_TREE;
 @@ -3328,7 +3328,7 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void 
 *data)
/* Avoid walking into the same tree more than once.  Unfortunately, we
   can't just use walk_tree_without_duplicates because it would only
   call us for the first occurrence of NRVs in the function body.  */
 -  if (pointer_set_insert (dp-visited, *tp))
 +  if (dp-visited-add (*tp))
  *walk_subtrees = 0;

return NULL_TREE;
 @@ -3376,13 +3376,13 @@ finalize_nrv (tree fndecl, bitmap nrv, vectree, 
 va_gc *other, Node_Id gnat_ret
data.nrv = nrv;
data.result = DECL_RESULT (fndecl);
data.gnat_ret = gnat_ret;
 -  data.visited = pointer_set_create ();
 +  data.visited = new hash_settree;
if (TYPE_RETURN_UNCONSTRAINED_P (TREE_TYPE (fndecl)))
  func = finalize_nrv_unc_r;
else
  func = finalize_nrv_r;
walk_tree (DECL_SAVED_TREE (fndecl), func, data, NULL);
 -  pointer_set_destroy (data.visited);
 +  delete data.visited;
  }

  /* Return true if RET_VAL can be used as a Named Return Value for the
 diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
 index 2b5ce5b..4898217 100644
 --- a/gcc/c-family/c-gimplify.c
 +++ b/gcc/c-family/c-gimplify.c
 @@ -74,7 +74,7 @@ along with GCC; see the file COPYING3.  If not see
  static tree
  ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
  {
 -  struct pointer_set_t *pset = (struct pointer_set_t *) data;
 +  hash_settree *pset = (hash_settree *) data;

/* Since walk_tree doesn't call the callback function on the decls
   in BIND_EXPR_VARS, we have to walk them manually.  */
 @@ -116,10 +116,9 @@ c_genericize (tree fndecl)

if (flag_sanitize  SANITIZE_BOUNDS)
  {
 -  struct pointer_set_t *pset = pointer_set_create ();
 -  walk_tree (DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, pset,
 -pset);
 -  pointer_set_destroy (pset);
 +  hash_settree pset;
 +  walk_tree (DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, pset,
 +pset);
  }

/* Dump the C-specific tree IR.  */
 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
 index 2a4b439..050ddff 100644
 --- a/gcc/c/c-decl.c
 +++ b/gcc/c/c-decl.c
 @@ -59,7 +59,7 @@ along with GCC; see the file COPYING3.  If not see
  #include cgraph.h
  #include hash-table.h
  #include langhooks-def.h
 -#include pointer-set.h
 +#include hash-set.h
  #include plugin.h
  #include 

[PATCH] add hash_set

2014-07-29 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

Hi,

this adds a hash_set wrapper around hash_table, and then replaces usage of 
pointer_set with it.

bootstrapped +regtested on x86_64-unknown-linux-gnu, ok?

Trev

ada/

* gcc-interface/trans.c: Use hash_set instead of pointer_set.

c-family/

* c-gimplify.c: Use hash_set instead of pointer_set.

c/

* c-decl.c: Use hash_set instead of pointer_set.

cp/

* class.c, cp-gimplify.c, cp-tree.h, decl.c, decl2.c, error.c,
method.c, name-lookup.c, pt.c, semantics.c, tree.c: Use hash_set
instead of pointer_set.

fortran/

* openmp.c, trans-decl.c: Use hash_set instead of pointer_set.

gcc/

* hash-set.h: new File.
* cfgexpand.c, cfgloop.c, cgraph.c, cgraphbuild.c, cgraphunit.c,
cprop.c, cse.c, gimple-walk.c, gimple-walk.h, gimplify.c, godump.c,
ipa-devirt.c, ipa-pure-const.c, ipa-visibility.c, ipa.c, lto-cgraph.c,
lto-streamer-out.c, stmt.c, tree-cfg.c, tree-core.h, tree-eh.c,
tree-inline.c, tree-inline.h, tree-nested.c, tree-pretty-print.c,
tree-ssa-loop-niter.c, tree-ssa-phiopt.c, tree-ssa-threadedge.c,
tree-ssa-uninit.c, tree.c, tree.h, value-prof.c, varasm.c,
varpool.c: Use hash_set instead of pointer_set.

lto/

* lto-partition.c, lto-partition.h: Use hash_set instead of
pointer_set.
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index f42ac7f..6961838 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -36,7 +36,7 @@
 #include output.h
 #include libfuncs.h  /* For set_stack_check_libfunc.  */
 #include tree-iterator.h
-#include pointer-set.h
+#include hash-set.h
 #include gimple-expr.h
 #include gimplify.h
 #include bitmap.h
@@ -3054,7 +3054,7 @@ struct nrv_data
   bitmap nrv;
   tree result;
   Node_Id gnat_ret;
-  struct pointer_set_t *visited;
+  hash_settree *visited;
 };
 
 /* Return true if T is a Named Return Value.  */
@@ -3188,7 +3188,7 @@ finalize_nrv_r (tree *tp, int *walk_subtrees, void *data)
   /* Avoid walking into the same tree more than once.  Unfortunately, we
  can't just use walk_tree_without_duplicates because it would only
  call us for the first occurrence of NRVs in the function body.  */
-  if (pointer_set_insert (dp-visited, *tp))
+  if (dp-visited-add (*tp))
 *walk_subtrees = 0;
 
   return NULL_TREE;
@@ -3328,7 +3328,7 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void 
*data)
   /* Avoid walking into the same tree more than once.  Unfortunately, we
  can't just use walk_tree_without_duplicates because it would only
  call us for the first occurrence of NRVs in the function body.  */
-  if (pointer_set_insert (dp-visited, *tp))
+  if (dp-visited-add (*tp))
 *walk_subtrees = 0;
 
   return NULL_TREE;
@@ -3376,13 +3376,13 @@ finalize_nrv (tree fndecl, bitmap nrv, vectree, va_gc 
*other, Node_Id gnat_ret
   data.nrv = nrv;
   data.result = DECL_RESULT (fndecl);
   data.gnat_ret = gnat_ret;
-  data.visited = pointer_set_create ();
+  data.visited = new hash_settree;
   if (TYPE_RETURN_UNCONSTRAINED_P (TREE_TYPE (fndecl)))
 func = finalize_nrv_unc_r;
   else
 func = finalize_nrv_r;
   walk_tree (DECL_SAVED_TREE (fndecl), func, data, NULL);
-  pointer_set_destroy (data.visited);
+  delete data.visited;
 }
 
 /* Return true if RET_VAL can be used as a Named Return Value for the
diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
index 2b5ce5b..4898217 100644
--- a/gcc/c-family/c-gimplify.c
+++ b/gcc/c-family/c-gimplify.c
@@ -74,7 +74,7 @@ along with GCC; see the file COPYING3.  If not see
 static tree
 ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
 {
-  struct pointer_set_t *pset = (struct pointer_set_t *) data;
+  hash_settree *pset = (hash_settree *) data;
 
   /* Since walk_tree doesn't call the callback function on the decls
  in BIND_EXPR_VARS, we have to walk them manually.  */
@@ -116,10 +116,9 @@ c_genericize (tree fndecl)
 
   if (flag_sanitize  SANITIZE_BOUNDS)
 {
-  struct pointer_set_t *pset = pointer_set_create ();
-  walk_tree (DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, pset,
-pset);
-  pointer_set_destroy (pset);
+  hash_settree pset;
+  walk_tree (DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, pset,
+pset);
 }
 
   /* Dump the C-specific tree IR.  */
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 2a4b439..050ddff 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -59,7 +59,7 @@ along with GCC; see the file COPYING3.  If not see
 #include cgraph.h
 #include hash-table.h
 #include langhooks-def.h
-#include pointer-set.h
+#include hash-set.h
 #include plugin.h
 #include c-family/c-ada-spec.h
 #include cilk.h
@@ -7221,17 +7221,17 @@ warn_cxx_compat_finish_struct (tree fieldlist)
   if (!struct_parse_info-typedefs_seen.is_empty ()
fieldlist != NULL_TREE)
 {
-