summaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-11 12:41:36 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-11 12:41:36 +0000
commit5737913a9a605694b55935563fc11e1e440b0351 (patch)
treefb9ef6a13039426828243cade216220f16250a8c /gcc/cgraph.c
parenta4ed3c38182dc43cc106abc06a2f76465989eb3f (diff)
downloadgcc-5737913a9a605694b55935563fc11e1e440b0351.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140285 138bc75d-0d04-0410-961f-82ee72b054a4
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 03e5e79d461..67a42ffba6b 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;
}