Commit 74ea4cd5 by Trevor Saunders Committed by Trevor Saunders

tree.c: add [cd]tors to free_lang_data_d

gcc/ChangeLog:

2016-07-12  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* tree.c (struct free_lang_data_d): Add constructor and change
	types of members to ones that automatically manage resources.
	(fld_worklist_push): Adjust.
	(find_decls_types): Likewise.
	(find_decls_types_in_eh_region): Likewise.
	(free_lang_data_in_cgraph): Stop manually creating and
	destroying members of free_lang_data_d.

From-SVN: r238278
parent 4aa59659
2016-07-12 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* tree.c (struct free_lang_data_d): Add constructor and change
types of members to ones that automatically manage resources.
(fld_worklist_push): Adjust.
(find_decls_types): Likewise.
(find_decls_types_in_eh_region): Likewise.
(free_lang_data_in_cgraph): Stop manually creating and
destroying members of free_lang_data_d.
2016-07-13 Uros Bizjak <ubizjak@gmail.com> 2016-07-13 Uros Bizjak <ubizjak@gmail.com>
PR rtl-optimization/68961 PR rtl-optimization/68961
......
...@@ -5500,17 +5500,19 @@ free_lang_data_in_decl (tree decl) ...@@ -5500,17 +5500,19 @@ free_lang_data_in_decl (tree decl)
struct free_lang_data_d struct free_lang_data_d
{ {
free_lang_data_d () : decls (100), types (100) {}
/* Worklist to avoid excessive recursion. */ /* Worklist to avoid excessive recursion. */
vec<tree> worklist; auto_vec<tree> worklist;
/* Set of traversed objects. Used to avoid duplicate visits. */ /* Set of traversed objects. Used to avoid duplicate visits. */
hash_set<tree> *pset; hash_set<tree> pset;
/* Array of symbols to process with free_lang_data_in_decl. */ /* Array of symbols to process with free_lang_data_in_decl. */
vec<tree> decls; auto_vec<tree> decls;
/* Array of types to process with free_lang_data_in_type. */ /* Array of types to process with free_lang_data_in_type. */
vec<tree> types; auto_vec<tree> types;
}; };
...@@ -5569,7 +5571,7 @@ add_tree_to_fld_list (tree t, struct free_lang_data_d *fld) ...@@ -5569,7 +5571,7 @@ add_tree_to_fld_list (tree t, struct free_lang_data_d *fld)
static inline void static inline void
fld_worklist_push (tree t, struct free_lang_data_d *fld) fld_worklist_push (tree t, struct free_lang_data_d *fld)
{ {
if (t && !is_lang_specific (t) && !fld->pset->contains (t)) if (t && !is_lang_specific (t) && !fld->pset.contains (t))
fld->worklist.safe_push ((t)); fld->worklist.safe_push ((t));
} }
...@@ -5738,8 +5740,8 @@ find_decls_types (tree t, struct free_lang_data_d *fld) ...@@ -5738,8 +5740,8 @@ find_decls_types (tree t, struct free_lang_data_d *fld)
{ {
while (1) while (1)
{ {
if (!fld->pset->contains (t)) if (!fld->pset.contains (t))
walk_tree (&t, find_decls_types_r, fld, fld->pset); walk_tree (&t, find_decls_types_r, fld, &fld->pset);
if (fld->worklist.is_empty ()) if (fld->worklist.is_empty ())
break; break;
t = fld->worklist.pop (); t = fld->worklist.pop ();
...@@ -5793,7 +5795,7 @@ find_decls_types_in_eh_region (eh_region r, struct free_lang_data_d *fld) ...@@ -5793,7 +5795,7 @@ find_decls_types_in_eh_region (eh_region r, struct free_lang_data_d *fld)
for (c = r->u.eh_try.first_catch; c ; c = c->next_catch) for (c = r->u.eh_try.first_catch; c ; c = c->next_catch)
{ {
c->type_list = get_eh_types_for_runtime (c->type_list); c->type_list = get_eh_types_for_runtime (c->type_list);
walk_tree (&c->type_list, find_decls_types_r, fld, fld->pset); walk_tree (&c->type_list, find_decls_types_r, fld, &fld->pset);
} }
} }
break; break;
...@@ -5801,12 +5803,12 @@ find_decls_types_in_eh_region (eh_region r, struct free_lang_data_d *fld) ...@@ -5801,12 +5803,12 @@ find_decls_types_in_eh_region (eh_region r, struct free_lang_data_d *fld)
case ERT_ALLOWED_EXCEPTIONS: case ERT_ALLOWED_EXCEPTIONS:
r->u.allowed.type_list r->u.allowed.type_list
= get_eh_types_for_runtime (r->u.allowed.type_list); = get_eh_types_for_runtime (r->u.allowed.type_list);
walk_tree (&r->u.allowed.type_list, find_decls_types_r, fld, fld->pset); walk_tree (&r->u.allowed.type_list, find_decls_types_r, fld, &fld->pset);
break; break;
case ERT_MUST_NOT_THROW: case ERT_MUST_NOT_THROW:
walk_tree (&r->u.must_not_throw.failure_decl, walk_tree (&r->u.must_not_throw.failure_decl,
find_decls_types_r, fld, fld->pset); find_decls_types_r, fld, &fld->pset);
break; break;
} }
} }
...@@ -5948,12 +5950,6 @@ free_lang_data_in_cgraph (void) ...@@ -5948,12 +5950,6 @@ free_lang_data_in_cgraph (void)
unsigned i; unsigned i;
alias_pair *p; alias_pair *p;
/* Initialize sets and arrays to store referenced decls and types. */
fld.pset = new hash_set<tree>;
fld.worklist.create (0);
fld.decls.create (100);
fld.types.create (100);
/* Find decls and types in the body of every function in the callgraph. */ /* Find decls and types in the body of every function in the callgraph. */
FOR_EACH_FUNCTION (n) FOR_EACH_FUNCTION (n)
find_decls_types_in_node (n, &fld); find_decls_types_in_node (n, &fld);
...@@ -5983,11 +5979,6 @@ free_lang_data_in_cgraph (void) ...@@ -5983,11 +5979,6 @@ free_lang_data_in_cgraph (void)
FOR_EACH_VEC_ELT (fld.types, i, t) FOR_EACH_VEC_ELT (fld.types, i, t)
verify_type (t); verify_type (t);
} }
delete fld.pset;
fld.worklist.release ();
fld.decls.release ();
fld.types.release ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment