aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2008-09-11 14:41:36 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2008-09-11 12:41:36 +0000
commit936fc9bad2df490917cbb01f27c9eede43f9e153 (patch)
treefb9ef6a13039426828243cade216220f16250a8c /gcc/cgraph.c
parentb1d0a338a77399b28670e657bfb1085a2b879384 (diff)
downloadgcc-936fc9bad2df490917cbb01f27c9eede43f9e153.zip
gcc-936fc9bad2df490917cbb01f27c9eede43f9e153.tar.gz
gcc-936fc9bad2df490917cbb01f27c9eede43f9e153.tar.bz2
cgraph.c (cgraph_release_function_body): Plug memory leak on ipa_transforms_to_apply and CFG...
* cgraph.c (cgraph_release_function_body): Plug memory leak on ipa_transforms_to_apply and CFG; ggc_free gimple df and struct function so we are sure we do not dangle it forever. * function.c (outer_function_chain, find_function_data): Remove. (function_context_stack): New. (push_function_context, pop_function_context): Update. * function.h (struct function): Remove pointer outer. (outer_function_chain, find_function_data): Remove. * stmt.c (force_label_rtx): Remove dead call of find_function_data. From-SVN: r140285
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 03e5e79..67a42ff 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -846,21 +846,34 @@ cgraph_node_remove_callers (struct cgraph_node *node)
void
cgraph_release_function_body (struct cgraph_node *node)
{
- if (DECL_STRUCT_FUNCTION (node->decl)
- && DECL_STRUCT_FUNCTION (node->decl)->gimple_df)
+ if (DECL_STRUCT_FUNCTION (node->decl))
{
tree old_decl = current_function_decl;
push_cfun (DECL_STRUCT_FUNCTION (node->decl));
- current_function_decl = node->decl;
- delete_tree_ssa ();
- delete_tree_cfg_annotations ();
- cfun->eh = NULL;
- gimple_set_body (node->decl, NULL);
- current_function_decl = old_decl;
+ if (cfun->gimple_df)
+ {
+ current_function_decl = node->decl;
+ delete_tree_ssa ();
+ delete_tree_cfg_annotations ();
+ cfun->eh = NULL;
+ current_function_decl = old_decl;
+ }
+ if (cfun->cfg)
+ {
+ gcc_assert (dom_computed[0] == DOM_NONE);
+ gcc_assert (dom_computed[1] == DOM_NONE);
+ clear_edges ();
+ }
pop_cfun();
+ gimple_set_body (node->decl, NULL);
+ VEC_free (ipa_opt_pass, heap,
+ DECL_STRUCT_FUNCTION (node->decl)->ipa_transforms_to_apply);
+ /* Struct function hangs a lot of data that would leak if we didn't
+ removed all pointers to it. */
+ ggc_free (DECL_STRUCT_FUNCTION (node->decl));
+ DECL_STRUCT_FUNCTION (node->decl) = NULL;
}
DECL_SAVED_TREE (node->decl) = NULL;
- DECL_STRUCT_FUNCTION (node->decl) = NULL;
DECL_INITIAL (node->decl) = error_mark_node;
}