Commit c8189787 by Martin Liska Committed by Martin Liska

Fix various memory leaks

	* gimple-ssa-strength-reduction.c (create_phi_basis):
	Use auto_vec.
	* passes.c (release_dump_file_name): New function.
	(pass_init_dump_file): Used from this function.
	(pass_fini_dump_file): Likewise.
	* tree-sra.c (convert_callers_for_node): Use xstrdup_for_dump.
	* var-tracking.c (vt_initialize): Use pool_allocator.

From-SVN: r230152
parent c0ab1970
2015-11-11 Martin Liska <mliska@suse.cz>
* gimple-ssa-strength-reduction.c (create_phi_basis):
Use auto_vec.
* passes.c (release_dump_file_name): New function.
(pass_init_dump_file): Used from this function.
(pass_fini_dump_file): Likewise.
* tree-sra.c (convert_callers_for_node): Use xstrdup_for_dump.
* var-tracking.c (vt_initialize): Use pool_allocator.
2015-11-11 Richard Biener <rguenth@gcc.gnu.org> 2015-11-11 Richard Biener <rguenth@gcc.gnu.org>
Jiong Wang <jiong.wang@arm.com> Jiong Wang <jiong.wang@arm.com>
...@@ -2226,12 +2226,11 @@ create_phi_basis (slsr_cand_t c, gimple *from_phi, tree basis_name, ...@@ -2226,12 +2226,11 @@ create_phi_basis (slsr_cand_t c, gimple *from_phi, tree basis_name,
int i; int i;
tree name, phi_arg; tree name, phi_arg;
gphi *phi; gphi *phi;
vec<tree> phi_args;
slsr_cand_t basis = lookup_cand (c->basis); slsr_cand_t basis = lookup_cand (c->basis);
int nargs = gimple_phi_num_args (from_phi); int nargs = gimple_phi_num_args (from_phi);
basic_block phi_bb = gimple_bb (from_phi); basic_block phi_bb = gimple_bb (from_phi);
slsr_cand_t phi_cand = base_cand_from_table (gimple_phi_result (from_phi)); slsr_cand_t phi_cand = base_cand_from_table (gimple_phi_result (from_phi));
phi_args.create (nargs); auto_vec<tree> phi_args (nargs);
/* Process each argument of the existing phi that represents /* Process each argument of the existing phi that represents
conditionally-executed add candidates. */ conditionally-executed add candidates. */
......
...@@ -2058,6 +2058,18 @@ verify_curr_properties (function *fn, void *data) ...@@ -2058,6 +2058,18 @@ verify_curr_properties (function *fn, void *data)
gcc_assert ((fn->curr_properties & props) == props); gcc_assert ((fn->curr_properties & props) == props);
} }
/* Release dump file name if set. */
static void
release_dump_file_name (void)
{
if (dump_file_name)
{
free (CONST_CAST (char *, dump_file_name));
dump_file_name = NULL;
}
}
/* Initialize pass dump file. */ /* Initialize pass dump file. */
/* This is non-static so that the plugins can use it. */ /* This is non-static so that the plugins can use it. */
...@@ -2071,6 +2083,7 @@ pass_init_dump_file (opt_pass *pass) ...@@ -2071,6 +2083,7 @@ pass_init_dump_file (opt_pass *pass)
gcc::dump_manager *dumps = g->get_dumps (); gcc::dump_manager *dumps = g->get_dumps ();
bool initializing_dump = bool initializing_dump =
!dumps->dump_initialized_p (pass->static_pass_number); !dumps->dump_initialized_p (pass->static_pass_number);
release_dump_file_name ();
dump_file_name = dumps->get_dump_file_name (pass->static_pass_number); dump_file_name = dumps->get_dump_file_name (pass->static_pass_number);
dumps->dump_start (pass->static_pass_number, &dump_flags); dumps->dump_start (pass->static_pass_number, &dump_flags);
if (dump_file && current_function_decl) if (dump_file && current_function_decl)
...@@ -2098,11 +2111,7 @@ pass_fini_dump_file (opt_pass *pass) ...@@ -2098,11 +2111,7 @@ pass_fini_dump_file (opt_pass *pass)
timevar_push (TV_DUMP); timevar_push (TV_DUMP);
/* Flush and close dump file. */ /* Flush and close dump file. */
if (dump_file_name) release_dump_file_name ();
{
free (CONST_CAST (char *, dump_file_name));
dump_file_name = NULL;
}
g->get_dumps ()->dump_finish (pass->static_pass_number); g->get_dumps ()->dump_finish (pass->static_pass_number);
timevar_pop (TV_DUMP); timevar_pop (TV_DUMP);
......
...@@ -4996,9 +4996,9 @@ convert_callers_for_node (struct cgraph_node *node, ...@@ -4996,9 +4996,9 @@ convert_callers_for_node (struct cgraph_node *node,
if (dump_file) if (dump_file)
fprintf (dump_file, "Adjusting call %s/%i -> %s/%i\n", fprintf (dump_file, "Adjusting call %s/%i -> %s/%i\n",
xstrdup (cs->caller->name ()), xstrdup_for_dump (cs->caller->name ()),
cs->caller->order, cs->caller->order,
xstrdup (cs->callee->name ()), xstrdup_for_dump (cs->callee->name ()),
cs->callee->order); cs->callee->order);
ipa_modify_call_arguments (cs, cs->call_stmt, *adjustments); ipa_modify_call_arguments (cs, cs->call_stmt, *adjustments);
......
...@@ -9814,7 +9814,7 @@ vt_initialize (void) ...@@ -9814,7 +9814,7 @@ vt_initialize (void)
alloc_aux_for_blocks (sizeof (variable_tracking_info)); alloc_aux_for_blocks (sizeof (variable_tracking_info));
empty_shared_hash = new shared_hash; empty_shared_hash = shared_hash_pool.allocate ();
empty_shared_hash->refcount = 1; empty_shared_hash->refcount = 1;
empty_shared_hash->htab = new variable_table_type (1); empty_shared_hash->htab = new variable_table_type (1);
changed_variables = new variable_table_type (10); changed_variables = new variable_table_type (10);
......
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