aboutsummaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2012-09-20 16:35:40 +0000
committerMartin Jambor <mjambor@suse.cz>2012-09-20 16:35:40 +0000
commita704de3f6db56790106a88d3787b918841bb5536 (patch)
treebd0847507cf2cc8fc2505732d6abf2f60dd73989 /gcc/function.c
parent61e2370527462cc82b24fbd91f145361b9b5ff4f (diff)
2012-09-20 Martin Jambor <mjambor@suse.cz>
* function.c (push_cfun): Check old current_function_decl matches old cfun, set new current_function_decl to the decl of the new cfun. (push_struct_function): Likewise. (pop_cfun): Likewise. (allocate_struct_function): Move call to invoke_set_current_function_hook to the end of the function. * cfgexpand.c (estimated_stack_frame_size): Do not set and restore current_function_decl. * cgraph.c (cgraph_release_function_body): Likewise. * cgraphunit.c (cgraph_process_new_functions): Likewise. (cgraph_add_new_function): Likewise. (cgraph_analyze_function): Likewise. (assemble_thunk): Set cfun to NULL at the end. (expand_function): Move call to set_cfun downwards. * gimple-low.c (record_vars_into): Only check current_function_decl before possibly doing push_cfun. * gimplify.c (gimplify_function_tree): Do not set and restore current_function_decl. * ipa-inline-analysis.c (compute_inline_parameters): Likewise. (inline_analyze_function): Likewise. * ipa-prop.c (ipa_analyze_node): Likewise. * ipa-pure-const.c (analyze_function): Likewise. * lto-streamer-in.c (lto_input_function_body): Do not set current_function_decl. * lto-streamer-out.c (output_function): Do not set and restore current_function_decl. * omp-low.c (finalize_task_copyfn): Likewise. (expand_omp_taskreg): Likewise. (create_task_copyfn): Likewise, move push_cfun up quite a bit. * passes.c (dump_passes): Do not set and restore current_function_decl. (do_per_function): Likewise. (do_per_function_toporder): Likewise. * trans-mem.c (ipa_tm_scan_irr_function): Likewise. (ipa_tm_transform_transaction): Likewise. (ipa_tm_transform_clone): Likewise. (ipa_tm_execute): Likewise. * tree-emutls.c (lower_emutls_function_body): Likewise. * tree-inline.c (initialize_cfun): Do not call pop_cfun. (tree_function_versioning): Do not call push_cfun, do not set and restore current_function_decl. Remove assert checking consistency of cfun and current_function_decl. * tree-profile.c (tree_profiling): Do not set and restore current_function_decl. * tree-sra.c (convert_callers_for_node): Do not set current_function_decl. (convert_callers): Do not restore current_function_decl. (modify_function): Do not set current_function_decl. * tree-ssa-structalias.c (ipa_pta_execute): Do not set and restore current_function_decl. fortran/ * trans-decl.c (gfc_get_extern_function_decl): Push NULL cfun. Do not set and restore current_function_decl. (gfc_init_coarray_decl): Do not set and restore current_function_decl. lto/ * lto.c (lto_materialize_function): Call push_struct_function and pop_cfun. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@191577 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/function.c')
-rw-r--r--gcc/function.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/gcc/function.c b/gcc/function.c
index ec21d9c3ea4..d6e19543753 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4412,22 +4412,34 @@ set_cfun (struct function *new_cfun)
static VEC(function_p,heap) *cfun_stack;
-/* Push the current cfun onto the stack, and set cfun to new_cfun. */
+/* Push the current cfun onto the stack, and set cfun to new_cfun. Also set
+ current_function_decl accordingly. */
void
push_cfun (struct function *new_cfun)
{
+ gcc_assert ((!cfun && !current_function_decl)
+ || (cfun && current_function_decl == cfun->decl));
VEC_safe_push (function_p, heap, cfun_stack, cfun);
+ current_function_decl = new_cfun ? new_cfun->decl : NULL_TREE;
set_cfun (new_cfun);
}
-/* Pop cfun from the stack. */
+/* Pop cfun from the stack. Also set current_function_decl accordingly. */
void
pop_cfun (void)
{
struct function *new_cfun = VEC_pop (function_p, cfun_stack);
+ /* When in_dummy_function, we do have a cfun but current_function_decl is
+ NULL. We also allow pushing NULL cfun and subsequently changing
+ current_function_decl to something else and have both restored by
+ pop_cfun. */
+ gcc_checking_assert (in_dummy_function
+ || !cfun
+ || current_function_decl == cfun->decl);
set_cfun (new_cfun);
+ current_function_decl = new_cfun ? new_cfun->decl : NULL_TREE;
}
/* Return value of funcdef and increase it. */
@@ -4474,8 +4486,6 @@ allocate_struct_function (tree fndecl, bool abstract_p)
OVERRIDE_ABI_FORMAT (fndecl);
#endif
- invoke_set_current_function_hook (fndecl);
-
if (fndecl != NULL_TREE)
{
DECL_STRUCT_FUNCTION (fndecl) = cfun;
@@ -4501,6 +4511,8 @@ allocate_struct_function (tree fndecl, bool abstract_p)
but is this worth the hassle? */
cfun->can_throw_non_call_exceptions = flag_non_call_exceptions;
}
+
+ invoke_set_current_function_hook (fndecl);
}
/* This is like allocate_struct_function, but pushes a new cfun for FNDECL
@@ -4509,7 +4521,13 @@ allocate_struct_function (tree fndecl, bool abstract_p)
void
push_struct_function (tree fndecl)
{
+ /* When in_dummy_function we might be in the middle of a pop_cfun and
+ current_function_decl and cfun may not match. */
+ gcc_assert (in_dummy_function
+ || (!cfun && !current_function_decl)
+ || (cfun && current_function_decl == cfun->decl));
VEC_safe_push (function_p, heap, cfun_stack, cfun);
+ current_function_decl = fndecl;
allocate_struct_function (fndecl, false);
}