PR jit/63854: Fix leak of ipa hooks
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 4 Dec 2014 21:11:04 +0000 (21:11 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Thu, 4 Dec 2014 21:11:04 +0000 (21:11 +0000)
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

gcc/ChangeLog
gcc/ipa-prop.c
gcc/ipa-reference.c
gcc/toplev.c

index 00edffe14807642e30e2f1000129b00f6d1ad70e..3efe39e9f8c94dab4aa977ed8b6e48f1de769d28 100644 (file)
@@ -1,3 +1,15 @@
+2014-12-04  David Malcolm  <dmalcolm@redhat.com>
+
+       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  <dmalcolm@redhat.com>
 
        * doc/cfg.texi (GIMPLE statement iterators): Add note about
index c6e7868989f7ae1438d39652220f4aea4a8ad031..eb83ae00baa4421833b15877bc027b219429dcee 100644 (file)
@@ -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);
 }
 
index 1ce06d126d63e6d733e61cbdf60d6e1460b2d9e3..b046f9ee1d0645ecc41804dbd5eed74bf21453bb 100644 (file)
@@ -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;
+    }
 }
index 2f547bfd9510b5c034b5d914d4930b2a6211dab6..911084db375cf24343f992dc2f1b793af3d93c67 100644 (file)
@@ -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 ();