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
This commit is contained in:
Martin Liska 2015-11-11 12:21:44 +01:00 committed by Martin Liska
parent c0ab1970b9
commit c81897872d
5 changed files with 28 additions and 10 deletions

View File

@ -1,3 +1,13 @@
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>
Jiong Wang <jiong.wang@arm.com>

View File

@ -2226,12 +2226,11 @@ create_phi_basis (slsr_cand_t c, gimple *from_phi, tree basis_name,
int i;
tree name, phi_arg;
gphi *phi;
vec<tree> phi_args;
slsr_cand_t basis = lookup_cand (c->basis);
int nargs = gimple_phi_num_args (from_phi);
basic_block phi_bb = gimple_bb (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
conditionally-executed add candidates. */

View File

@ -2058,6 +2058,18 @@ verify_curr_properties (function *fn, void *data)
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. */
/* This is non-static so that the plugins can use it. */
@ -2071,6 +2083,7 @@ pass_init_dump_file (opt_pass *pass)
gcc::dump_manager *dumps = g->get_dumps ();
bool initializing_dump =
!dumps->dump_initialized_p (pass->static_pass_number);
release_dump_file_name ();
dump_file_name = dumps->get_dump_file_name (pass->static_pass_number);
dumps->dump_start (pass->static_pass_number, &dump_flags);
if (dump_file && current_function_decl)
@ -2098,11 +2111,7 @@ pass_fini_dump_file (opt_pass *pass)
timevar_push (TV_DUMP);
/* Flush and close dump file. */
if (dump_file_name)
{
free (CONST_CAST (char *, dump_file_name));
dump_file_name = NULL;
}
release_dump_file_name ();
g->get_dumps ()->dump_finish (pass->static_pass_number);
timevar_pop (TV_DUMP);

View File

@ -4996,9 +4996,9 @@ convert_callers_for_node (struct cgraph_node *node,
if (dump_file)
fprintf (dump_file, "Adjusting call %s/%i -> %s/%i\n",
xstrdup (cs->caller->name ()),
xstrdup_for_dump (cs->caller->name ()),
cs->caller->order,
xstrdup (cs->callee->name ()),
xstrdup_for_dump (cs->callee->name ()),
cs->callee->order);
ipa_modify_call_arguments (cs, cs->call_stmt, *adjustments);

View File

@ -9814,7 +9814,7 @@ vt_initialize (void)
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->htab = new variable_table_type (1);
changed_variables = new variable_table_type (10);