From: David Malcolm Date: Thu, 4 Dec 2014 21:11:04 +0000 (+0000) Subject: PR jit/63854: Fix leak of ipa hooks X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=953971cf7dd11ab68caec04cae767f5dde656b23;p=gcc.git PR jit/63854: Fix leak of ipa hooks gcc/ChangeLog: PR jit/63854 * ipa-prop.c (ipa_register_cgraph_hooks): Guard insertion of ipa_add_new_function on function_insertion_hook_holder being non-NULL. * ipa-reference.c (ipa_reference_c_finalize): Remove node_removal_hook_holder and node_duplication_hook_holder if they've been added to symtab. * toplev.c (toplev::finalize): Call ipa_reference_c_finalize before cgraph_c_finalize so that the former can access "symtab". From-SVN: r218403 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 00edffe1480..3efe39e9f8c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2014-12-04 David Malcolm + + PR jit/63854 + * ipa-prop.c (ipa_register_cgraph_hooks): Guard insertion of + ipa_add_new_function on function_insertion_hook_holder being + non-NULL. + * ipa-reference.c (ipa_reference_c_finalize): Remove + node_removal_hook_holder and node_duplication_hook_holder if + they've been added to symtab. + * toplev.c (toplev::finalize): Call ipa_reference_c_finalize + before cgraph_c_finalize so that the former can access "symtab". + 2014-12-04 David Malcolm * doc/cfg.texi (GIMPLE statement iterators): Add note about diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index c6e7868989f..eb83ae00baa 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -3613,7 +3613,8 @@ ipa_register_cgraph_hooks (void) if (!node_duplication_hook_holder) node_duplication_hook_holder = symtab->add_cgraph_duplication_hook (&ipa_node_duplication_hook, NULL); - function_insertion_hook_holder = + if (!function_insertion_hook_holder) + function_insertion_hook_holder = symtab->add_cgraph_insertion_hook (&ipa_add_new_function, NULL); } diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 1ce06d126d6..b046f9ee1d0 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -1198,4 +1198,15 @@ ipa_reference_c_finalize (void) bitmap_obstack_release (&optimization_summary_obstack); ipa_init_p = false; } + + if (node_removal_hook_holder) + { + symtab->remove_cgraph_removal_hook (node_removal_hook_holder); + node_removal_hook_holder = NULL; + } + if (node_duplication_hook_holder) + { + symtab->remove_cgraph_duplication_hook (node_duplication_hook_holder); + node_duplication_hook_holder = NULL; + } } diff --git a/gcc/toplev.c b/gcc/toplev.c index 2f547bfd951..911084db375 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2163,12 +2163,14 @@ toplev::finalize (void) rtl_initialized = false; this_target_rtl->target_specific_initialized = false; + /* Needs to be called before cgraph_c_finalize since it uses symtab. */ + ipa_reference_c_finalize (); + cgraph_c_finalize (); cgraphunit_c_finalize (); dwarf2out_c_finalize (); gcse_c_finalize (); ipa_cp_c_finalize (); - ipa_reference_c_finalize (); ira_costs_c_finalize (); params_c_finalize ();