+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.
+
2012-09-20 Diego Novillo <dnovillo@google.com>
PR target/54631
HOST_WIDE_INT size = 0;
size_t i;
tree var;
- tree old_cur_fun_decl = current_function_decl;
struct function *fn = DECL_STRUCT_FUNCTION (node->symbol.decl);
- current_function_decl = node->symbol.decl;
push_cfun (fn);
init_vars_expansion ();
fini_vars_expansion ();
pop_cfun ();
- current_function_decl = old_cur_fun_decl;
return size;
}
{
if (DECL_STRUCT_FUNCTION (node->symbol.decl))
{
- tree old_decl = current_function_decl;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
if (cfun->cfg
&& current_loops)
}
if (cfun->gimple_df)
{
- current_function_decl = node->symbol.decl;
delete_tree_ssa ();
delete_tree_cfg_annotations ();
cfun->eh = NULL;
- current_function_decl = old_decl;
}
if (cfun->cfg)
{
if (!node->analyzed)
cgraph_analyze_function (node);
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
- current_function_decl = fndecl;
if ((cgraph_state == CGRAPH_STATE_IPA_SSA
&& !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
/* When not optimizing, be sure we run early local passes anyway
free_dominance_info (CDI_POST_DOMINATORS);
free_dominance_info (CDI_DOMINATORS);
pop_cfun ();
- current_function_decl = NULL;
cgraph_call_function_insertion_hooks (node);
break;
if (!lowered && cgraph_state == CGRAPH_STATE_EXPANSION)
{
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
- current_function_decl = fndecl;
gimple_register_cfg_hooks ();
bitmap_obstack_initialize (NULL);
execute_pass_list (all_lowering_passes);
execute_pass_list (pass_early_local_passes.pass.sub);
bitmap_obstack_release (NULL);
pop_cfun ();
- current_function_decl = NULL;
lowered = true;
}
node->lowered = true;
cgraph_analyze_function (node);
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
- current_function_decl = fndecl;
gimple_register_cfg_hooks ();
bitmap_obstack_initialize (NULL);
if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
bitmap_obstack_release (NULL);
pop_cfun ();
expand_function (node);
- current_function_decl = NULL;
break;
default:
static void
cgraph_analyze_function (struct cgraph_node *node)
{
- tree save = current_function_decl;
tree decl = node->symbol.decl;
location_t saved_loc = input_location;
input_location = DECL_SOURCE_LOCATION (decl);
}
else
{
- current_function_decl = decl;
push_cfun (DECL_STRUCT_FUNCTION (decl));
assign_assembler_name_if_neeeded (node->symbol.decl);
}
node->analyzed = true;
- current_function_decl = save;
input_location = saved_loc;
}
bitmap_obstack_release (NULL);
}
current_function_decl = NULL;
+ set_cfun (NULL);
}
/* Release the default bitmap obstack. */
bitmap_obstack_release (NULL);
- set_cfun (NULL);
-
/* If requested, warn about function definitions where the function will
return a value (usually of some struct or union type) which itself will
take up a lot of stack space. */
/* Make sure that BE didn't give up on compiling. */
gcc_assert (TREE_ASM_WRITTEN (decl));
+ set_cfun (NULL);
current_function_decl = NULL;
/* It would make a lot more sense to output thunks before function body to get more
+2012-09-20 Martin Jambor <mjambor@suse.cz>
+
+ * 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.
+
2012-09-17 Tobias Burnus <burnus@net-b.de>
PR fortran/54608
/* By construction, the external function cannot be
a contained procedure. */
locus old_loc;
- tree save_fn_decl = current_function_decl;
- current_function_decl = NULL_TREE;
gfc_save_backend_locus (&old_loc);
- push_cfun (cfun);
+ push_cfun (NULL);
gfc_create_function_decl (gsym->ns, true);
pop_cfun ();
gfc_restore_backend_locus (&old_loc);
- current_function_decl = save_fn_decl;
}
/* If the namespace has entries, the proc_name is the
void
gfc_init_coarray_decl (bool main_tu)
{
- tree save_fn_decl;
-
if (gfc_option.coarray != GFC_FCOARRAY_LIB)
return;
if (gfort_gvar_caf_this_image || gfort_gvar_caf_num_images)
return;
- save_fn_decl = current_function_decl;
- current_function_decl = NULL_TREE;
push_cfun (cfun);
gfort_gvar_caf_this_image
pushdecl_top_level (gfort_gvar_caf_num_images);
pop_cfun ();
- current_function_decl = save_fn_decl;
}
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. */
OVERRIDE_ABI_FORMAT (fndecl);
#endif
- invoke_set_current_function_hook (fndecl);
-
if (fndecl != NULL_TREE)
{
DECL_STRUCT_FUNCTION (fndecl) = cfun;
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
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);
}
void
record_vars_into (tree vars, tree fn)
{
- if (fn != current_function_decl)
+ bool change_cfun = fn != current_function_decl;
+
+ if (change_cfun)
push_cfun (DECL_STRUCT_FUNCTION (fn));
for (; vars; vars = DECL_CHAIN (vars))
add_local_decl (cfun, var);
}
- if (fn != current_function_decl)
+ if (change_cfun)
pop_cfun ();
}
void
gimplify_function_tree (tree fndecl)
{
- tree oldfn, parm, ret;
+ tree parm, ret;
gimple_seq seq;
gimple bind;
gcc_assert (!gimple_body (fndecl));
- oldfn = current_function_decl;
- current_function_decl = fndecl;
if (DECL_STRUCT_FUNCTION (fndecl))
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
else
DECL_SAVED_TREE (fndecl) = NULL_TREE;
cfun->curr_properties = PROP_gimple_any;
- current_function_decl = oldfn;
pop_cfun ();
}
HOST_WIDE_INT self_stack_size;
struct cgraph_edge *e;
struct inline_summary *info;
- tree old_decl = current_function_decl;
gcc_assert (!node->global.inlined_to);
}
/* Even is_gimple_min_invariant rely on current_function_decl. */
- current_function_decl = node->symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
/* Estimate the stack size for the function if we're optimizing. */
info->size = info->self_size;
info->stack_frame_offset = 0;
info->estimated_stack_size = info->estimated_self_stack_size;
- current_function_decl = old_decl;
pop_cfun ();
}
inline_analyze_function (struct cgraph_node *node)
{
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- current_function_decl = node->symbol.decl;
if (dump_file)
fprintf (dump_file, "\nAnalyzing function: %s/%u\n",
inline_indirect_intraprocedural_analysis (node);
compute_inline_parameters (node, false);
- current_function_decl = NULL;
pop_cfun ();
}
ipa_check_create_edge_args ();
info = IPA_NODE_REF (node);
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- current_function_decl = node->symbol.decl;
ipa_initialize_node_params (node);
param_count = ipa_get_param_count (info);
BITMAP_FREE (parms_ainfo[i].pt_visited_statements);
}
- current_function_decl = NULL;
pop_cfun ();
}
analyze_function (struct cgraph_node *fn, bool ipa)
{
tree decl = fn->symbol.decl;
- tree old_decl = current_function_decl;
funct_state l;
basic_block this_block;
}
push_cfun (DECL_STRUCT_FUNCTION (decl));
- current_function_decl = decl;
FOR_EACH_BB (this_block)
{
l->can_throw = false;
pop_cfun ();
- current_function_decl = old_decl;
if (dump_file)
{
if (l->looping)
lto_input_function_body (struct lto_file_decl_data *file_data,
tree fn_decl, const char *data)
{
- current_function_decl = fn_decl;
lto_read_body (file_data, fn_decl, data, LTO_section_function_body);
}
gcc_assert (current_function_decl == NULL_TREE && cfun == NULL);
/* Set current_function_decl and cfun. */
- current_function_decl = function;
push_cfun (fn);
/* Make string 0 be a NULL string. */
destroy_output_block (ob);
- current_function_decl = NULL;
pop_cfun ();
}
+2012-09-20 Martin Jambor <mjambor@suse.cz>
+
+ * lto.c (lto_materialize_function): Call push_struct_function and
+ pop_cfun.
+
2012-09-19 Dehao Chen <dehao@google.com>
* lto/lto.c (lto_fixup_prevailing_decls): Remove tree.exp.block field.
gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL);
- allocate_struct_function (decl, false);
+ push_struct_function (decl);
announce_function (decl);
lto_input_function_body (file_data, decl, data);
if (DECL_FUNCTION_PERSONALITY (decl) && !first_personality_decl)
lto_stats.num_function_bodies++;
lto_free_section_data (file_data, LTO_section_function_body, name,
data, len);
+ pop_cfun ();
ggc_collect ();
}
}
finalize_task_copyfn (gimple task_stmt)
{
struct function *child_cfun;
- tree child_fn, old_fn;
+ tree child_fn;
gimple_seq seq = NULL, new_seq;
gimple bind;
DECL_STRUCT_FUNCTION (child_fn)->curr_properties
= cfun->curr_properties & ~PROP_loops;
- old_fn = current_function_decl;
push_cfun (child_cfun);
- current_function_decl = child_fn;
bind = gimplify_body (child_fn, false);
gimple_seq_add_stmt (&seq, bind);
new_seq = maybe_catch_exception (seq);
}
gimple_set_body (child_fn, seq);
pop_cfun ();
- current_function_decl = old_fn;
cgraph_add_new_function (child_fn, false);
}
basic_block entry_bb, exit_bb, new_bb;
struct function *child_cfun;
tree child_fn, block, t;
- tree save_current;
gimple_stmt_iterator gsi;
gimple entry_stmt, stmt;
edge e;
/* Fix the callgraph edges for child_cfun. Those for cfun will be
fixed in a following pass. */
push_cfun (child_cfun);
- save_current = current_function_decl;
- current_function_decl = child_fn;
if (optimize)
optimize_omp_library_calls (entry_stmt);
rebuild_cgraph_edges ();
}
if (gimple_in_ssa_p (cfun))
update_ssa (TODO_update_ssa);
- current_function_decl = save_current;
pop_cfun ();
}
/* Populate the function. */
push_gimplify_context (&gctx);
- current_function_decl = child_fn;
+ push_cfun (child_cfun);
bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
TREE_SIDE_EFFECTS (bind) = 1;
else
tcctx.cb.decl_map = NULL;
- push_cfun (child_cfun);
-
arg = DECL_ARGUMENTS (child_fn);
TREE_TYPE (arg) = build_pointer_type (record_type);
sarg = DECL_CHAIN (arg);
pop_gimplify_context (NULL);
BIND_EXPR_BODY (bind) = list;
pop_cfun ();
- current_function_decl = ctx->cb.src_fn;
}
/* Lower the OpenMP parallel or task directive in the current statement
dump_passes (void)
{
struct cgraph_node *n, *node = NULL;
- tree save_fndecl = current_function_decl;
create_pass_tab();
return;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- current_function_decl = node->symbol.decl;
dump_pass_list (all_lowering_passes, 1);
dump_pass_list (all_small_ipa_passes, 1);
dump_pass_list (all_passes, 1);
pop_cfun ();
- current_function_decl = save_fndecl;
}
&& (!node->clone_of || node->symbol.decl != node->clone_of->symbol.decl))
{
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- current_function_decl = node->symbol.decl;
callback (data);
if (!flag_wpa)
{
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
}
- current_function_decl = NULL;
pop_cfun ();
ggc_collect ();
}
if (cgraph_function_with_gimple_body_p (node))
{
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- current_function_decl = node->symbol.decl;
callback (data);
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
- current_function_decl = NULL;
pop_cfun ();
ggc_collect ();
}
|| DECL_STRUCT_FUNCTION (node->symbol.decl)->cfg == NULL)
return false;
- current_function_decl = node->symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
calculate_dominance_info (CDI_DOMINATORS);
VEC_free (basic_block, heap, queue);
pop_cfun ();
- current_function_decl = NULL;
return ret;
}
d = get_cg_data (&node, true);
- current_function_decl = node->symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
calculate_dominance_info (CDI_DOMINATORS);
update_ssa (TODO_update_ssa_only_virtuals);
pop_cfun ();
- current_function_decl = NULL;
}
/* Transform the calls within the transactional clone of NODE. */
if (!node->callees && !node->indirect_calls && !d->irrevocable_blocks_clone)
return;
- current_function_decl = d->clone->symbol.decl;
- push_cfun (DECL_STRUCT_FUNCTION (current_function_decl));
+ push_cfun (DECL_STRUCT_FUNCTION (d->clone->symbol.decl));
calculate_dominance_info (CDI_DOMINATORS);
need_ssa_rename =
update_ssa (TODO_update_ssa_only_virtuals);
pop_cfun ();
- current_function_decl = NULL;
}
/* Main entry point for the transactional memory IPA pass. */
continue;
}
- current_function_decl = node->symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
calculate_dominance_info (CDI_DOMINATORS);
}
pop_cfun ();
- current_function_decl = NULL;
}
/* For every local function on the callee list, scan as if we will be
struct lower_emutls_data d;
bool any_edge_inserts = false;
- current_function_decl = node->symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
d.cfun_node = node;
gsi_commit_edge_inserts ();
pop_cfun ();
- current_function_decl = NULL;
}
/* Create emutls variable for VAR, DATA is pointer to static
}
/* Build struct function and associated datastructures for the new clone
- NEW_FNDECL to be build. CALLEE_FNDECL is the original */
+ NEW_FNDECL to be build. CALLEE_FNDECL is the original. Function changes
+ the cfun to the function of new_fndecl (and current_function_decl too). */
static void
initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count)
cfun->gimple_df->in_ssa_p = true;
init_ssa_operands (cfun);
}
- pop_cfun ();
}
/* Helper function for copy_cfg_body. Move debug stmts from the end
struct ipa_replace_map *replace_info;
basic_block old_entry_block, bb;
VEC (gimple, heap) *init_stmts = VEC_alloc (gimple, heap, 10);
-
- tree old_current_function_decl = current_function_decl;
tree vars = NULL_TREE;
gcc_assert (TREE_CODE (old_decl) == FUNCTION_DECL
id.transform_return_to_modify = false;
id.transform_lang_insert_block = NULL;
- current_function_decl = new_decl;
old_entry_block = ENTRY_BLOCK_PTR_FOR_FUNCTION
(DECL_STRUCT_FUNCTION (old_decl));
initialize_cfun (new_decl, old_decl,
old_entry_block->count);
DECL_STRUCT_FUNCTION (new_decl)->gimple_df->ipa_pta
= id.src_cfun->gimple_df->ipa_pta;
- push_cfun (DECL_STRUCT_FUNCTION (new_decl));
/* Copy the function's static chain. */
p = DECL_STRUCT_FUNCTION (old_decl)->static_chain_decl;
gcc_assert (!id.debug_stmts);
VEC_free (gimple, heap, init_stmts);
pop_cfun ();
- current_function_decl = old_current_function_decl;
- gcc_assert (!current_function_decl
- || DECL_STRUCT_FUNCTION (current_function_decl) == cfun);
return;
}
continue;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- current_function_decl = node->symbol.decl;
/* Local pure-const may imply need to fixup the cfg. */
if (execute_fixup_cfg () & TODO_cleanup_cfg)
easy to adjust it, if and when there is some. */
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
-
- current_function_decl = NULL;
pop_cfun ();
}
continue;
push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- current_function_decl = node->symbol.decl;
FOR_EACH_BB (bb)
{
rebuild_cgraph_edges ();
- current_function_decl = NULL;
pop_cfun ();
}
for (cs = node->callers; cs; cs = cs->next_caller)
{
- current_function_decl = cs->caller->symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (cs->caller->symbol.decl));
if (dump_file)
convert_callers (struct cgraph_node *node, tree old_decl,
ipa_parm_adjustment_vec adjustments)
{
- tree old_cur_fndecl = current_function_decl;
basic_block this_block;
cgraph_for_node_and_aliases (node, convert_callers_for_node,
adjustments, false);
- current_function_decl = old_cur_fndecl;
-
if (!encountered_recursive_call)
return;
rebuild_cgraph_edges ();
free_dominance_info (CDI_DOMINATORS);
pop_cfun ();
- current_function_decl = NULL_TREE;
new_node = cgraph_function_versioning (node, redirect_callers, NULL, NULL,
false, NULL, NULL, "isra");
VEC_free (cgraph_edge_p, heap, redirect_callers);
- current_function_decl = new_node->symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (new_node->symbol.decl));
-
ipa_modify_formal_parameters (current_function_decl, adjustments, "ISRA");
cfg_changed = ipa_sra_modify_function_body (adjustments);
sra_ipa_reset_debug_stmts (adjustments);
{
struct function *func;
basic_block bb;
- tree old_func_decl;
/* Nodes without a body are not interesting. */
if (!cgraph_function_with_gimple_body_p (node))
}
func = DECL_STRUCT_FUNCTION (node->symbol.decl);
- old_func_decl = current_function_decl;
push_cfun (func);
- current_function_decl = node->symbol.decl;
/* For externally visible or attribute used annotated functions use
local constraints for their arguments.
}
}
- current_function_decl = old_func_decl;
pop_cfun ();
if (dump_file)