From db2960f402c407aa41fe09d5195da5c414ae79af Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Wed, 5 Sep 2007 10:24:54 -0400 Subject: Add target hook invoked when cfun changes. 2007-09-05 Sandra Loosemore gcc/ Add target hook invoked when cfun changes. * doc/tm.texi (TARGET_SET_CURRENT_FUNCTION): Document. * target.h (struct gcc_target): Add set_current_function. * target-def.h (TARGET_SET_CURRENT_FUNCTION): Define. (TARGET_INITIALIZER): Add initializer for set_current_function. * tree.h (push_struct_function): New. * tree-inline.h (push_cfun, pop_cfun): Move declarations to... * function.h: Here. (set_cfun): Declare. * tree-inline.c (cfun_stack, push_cfun, pop_cfun): Moved to... * function.c: Here. (push_function_context_to): Use allocate_struct_function to create null context, not init_dummy_function_start. Use set_cfun. (pop_function_context_from): Use set_cfun. (in_dummy_function): New. (invoke_set_current_function_hook): New. (set_cfun): New. (push_cfun, pop_cfun): Use set_cfun. (push_struct_function): New. (allocate_struct_function): Call invoke_set_current_function_hook before returning. (prepare_function_start): Don't set cfun here. Remove unused argument; fix all callers. (init_dummy_function_start): Fiddle with in_dummy_function. Call push_struct_function. (init_function_start): Set cfun here. (expand_dummy_function_end): Fiddle with in_dummy_function. Pop cfun. * omp-low.c (create_omp_child_function): Use push_struct_function and pop_cfun to save/restore state. (expand_omp_parallel): Remove unused saved_cfun variable. * cgraphunit.c (ipa_passes): Use set_cfun. * gimple-low.c (record_vars_into): Use push_cfun/pop_cfun here. * dwarf2out.c (dwarf2out_abstract_function): Likewise. * matrix-reorg.c (transform_allocation_sites): Likewise. (matrix_reorg): Use set_cfun. * gimplify.c (gimplify_function_tree): Use push_cfun/pop_cfun here. * tree-optimize.c (tree_rest_of_compilation): Remove one redundant assignment to cfun; use set_cfun for the other. * tree-cfg.c (move_sese_region_to_fn): Use set_cfun. (dump_function_to_file): Use push_cfun/pop_cfun here. * c-decl.c (finish_function): Use set_cfun. gcc/ada/ * trans.c (Compilation_unit_to_gnu): Use set_cfun. * utils.c (end_subprog_body): Likewise. gcc/cp/ * decl.c (finish_function): Use set_cfun. * method.c (use_thunk): Likewise. gcc/fortran/ * trans-decl.c (build_entry_thunks): Use set_cfun. (gfc_generate_function_code): Likewise. gcc/java/ * decl.c (finish_method): Use set_cfun. gcc/treelang/ * treetree.c (tree_code_create_function_wrapup): Use set_cfun. From-SVN: r128132 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/trans.c | 2 +- gcc/ada/utils.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'gcc/ada') diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5565cb8..30eab69 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2007-09-05 Sandra Loosemore + + * trans.c (Compilation_unit_to_gnu): Use set_cfun. + * utils.c (end_subprog_body): Likewise. + 2007-09-03 Nick Clifton * Make-lang.in: Change copyright header to refer to version 3 of diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index f6ba98c..4d79cb3 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -2874,7 +2874,7 @@ Compilation_Unit_to_gnu (Node_Id gnat_node) DECL_ELABORATION_PROC_P (gnu_elab_proc_decl) = 1; allocate_struct_function (gnu_elab_proc_decl); Sloc_to_locus (Sloc (gnat_unit_entity), &cfun->function_end_locus); - cfun = 0; + set_cfun (NULL); /* For a body, first process the spec if there is one. */ if (Nkind (Unit (gnat_node)) == N_Package_Body diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 037b3b9..6a4cc3c 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -2119,7 +2119,7 @@ end_subprog_body (tree body) DECL_SAVED_TREE (fndecl) = body; current_function_decl = DECL_CONTEXT (fndecl); - cfun = NULL; + set_cfun (NULL); /* We cannot track the location of errors past this point. */ error_gnat_node = Empty; -- cgit v1.1