> This cleans up allocation/deallocation of reference_vars_to_consider, > specifically always releasing the vector allocated in ipa_init and > also making sure to release it before re-allocating it in > ipa_reference_write_optimization_summary. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? > > Thanks, > Richard. > > 2021-02-10 Richard Biener <rguent...@suse.de> > > PR ipa/97346 > * ipa-reference.c (propagate): Always free > reference_vars_to_consider. > (ipa_reference_write_optimization_summary): Free > reference_vars_to_consider before re-allocating it. > (ipa_reference_write_optimization_summary): Use vec_free > and NULL reference_vars_to_consider.
Hi, this is version I commited after discussion on the PR (it makes it more explicit that reference_vars_to_consider are used during analysis only to aid dumping). Honza 2021-02-14 Jan Hubicka <hubi...@ucw.cz> Richard Biener <rguet...@suse.de> PR ipa/97346 * ipa-reference.c (ipa_init): Only conditinally initialize reference_vars_to_consider. (propagate): Conditionally deninitialize reference_vars_to_consider. (ipa_reference_write_optimization_summary): Sanity check that reference_vars_to_consider is not allocated. diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 2ea2a6d5327..6cf78ff94a6 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -458,8 +458,8 @@ ipa_init (void) ipa_init_p = true; - vec_alloc (reference_vars_to_consider, 10); - + if (dump_file) + vec_alloc (reference_vars_to_consider, 10); if (ipa_ref_opt_sum_summaries != NULL) { @@ -967,8 +967,12 @@ propagate (void) } if (dump_file) - vec_free (reference_vars_to_consider); - reference_vars_to_consider = NULL; + { + vec_free (reference_vars_to_consider); + reference_vars_to_consider = NULL; + } + else + gcc_checking_assert (!reference_vars_to_consider); return remove_p ? TODO_remove_functions : 0; } @@ -1059,6 +1063,7 @@ ipa_reference_write_optimization_summary (void) auto_bitmap ltrans_statics; int i; + gcc_checking_assert (!reference_vars_to_consider); vec_alloc (reference_vars_to_consider, ipa_reference_vars_uids); reference_vars_to_consider->safe_grow (ipa_reference_vars_uids, true); @@ -1117,7 +1122,8 @@ ipa_reference_write_optimization_summary (void) } } lto_destroy_simple_output_block (ob); - delete reference_vars_to_consider; + vec_free (reference_vars_to_consider); + reference_vars_to_consider = NULL; } /* Deserialize the ipa info for lto. */