From 936fc9bad2df490917cbb01f27c9eede43f9e153 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 11 Sep 2008 14:41:36 +0200 Subject: 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 --- gcc/function.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'gcc/function.c') diff --git a/gcc/function.c b/gcc/function.c index 412e6fa9af0..41c5a46a621 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -208,23 +208,14 @@ static void do_clobber_return_reg (rtx, void *); static void do_use_return_reg (rtx, void *); static void set_insn_locators (rtx, int) ATTRIBUTE_UNUSED; -/* Pointer to chain of `struct function' for containing functions. */ -struct function *outer_function_chain; - -/* Given a function decl for a containing function, - return the `struct function' for it. */ - -struct function * -find_function_data (tree decl) -{ - struct function *p; +/* Stack of nested functions. */ +/* Keep track of the cfun stack. */ - for (p = outer_function_chain; p; p = p->outer) - if (p->decl == decl) - return p; +typedef struct function *function_p; - gcc_unreachable (); -} +DEF_VEC_P(function_p); +DEF_VEC_ALLOC_P(function_p,heap); +static VEC(function_p,heap) *function_context_stack; /* Save the current context for compilation of a nested function. This is called from language-specific code. */ @@ -235,8 +226,7 @@ push_function_context (void) if (cfun == 0) allocate_struct_function (NULL, false); - cfun->outer = outer_function_chain; - outer_function_chain = cfun; + VEC_safe_push (function_p, heap, function_context_stack, cfun); set_cfun (NULL); } @@ -246,10 +236,8 @@ push_function_context (void) void pop_function_context (void) { - struct function *p = outer_function_chain; - + struct function *p = VEC_pop (function_p, function_context_stack); set_cfun (p); - outer_function_chain = p->outer; current_function_decl = p->decl; /* Reset variables that have known state during rtx generation. */ @@ -3905,13 +3893,6 @@ set_cfun (struct function *new_cfun) } } -/* Keep track of the cfun stack. */ - -typedef struct function *function_p; - -DEF_VEC_P(function_p); -DEF_VEC_ALLOC_P(function_p,heap); - /* Initialized with NOGC, making this poisonous to the garbage collector. */ static VEC(function_p,heap) *cfun_stack; -- cgit v1.2.1