aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2012-08-24 12:57:24 +0000
committerMartin Jambor <mjambor@suse.cz>2012-08-24 12:57:24 +0000
commitad820100fd978e72fc043f4f031533baaad6ef15 (patch)
treeb1213a8631b75e45f38fd88f7776c25b9fafe3b3 /gcc/tree-cfg.c
parentf88026d9383e1e0eeadd3ff32cafcde7242e058e (diff)
2012-08-24 Martin Jambor <mjambor@suse.cz>
* predict.c (maybe_hot_frequency_p): New parameter fun. Use its decl instead of current_function_decl, use profile_status_for_function and ENTRY_BLOCK_PTR_FOR_FUNCTION with fun instead of their cfun variants. (maybe_hot_count_p): New parameter fun, use profile_status_for_function instead of its cfun_variant. (maybe_hot_bb_p): New parameter fun, checking-assert it, pass it to all callees. (maybe_hot_edge_p): Pass cfun to maybe_hot_count_p and maybe_hot_frequency_p. (probably_never_executed_bb_p): New parameter fun, use its decl instead of current_function_decl. (optimize_bb_for_size_p): Pass cfun to maybe_hot_bb_p. (rtl_profile_for_bb): Likewise. (compute_function_frequency): Pass cfun to maybe_hot_bb_p and probably_never_executed_bb_p. * tree-ssa-operands.c (ssa_operands_active): New operator fun. Use it instead of cfun. (update_stmt_operands): Pass cfun as an argument of ssa_operands_active. (swap_tree_operands): Likewise. * gimple-iterator.c (update_modified_stmt): Likewise. (update_modified_stmts): Likewise. * tree-flow-inline.h (delink_stmt_imm_use): Likewise. * tree-ssa.c (delete_tree_ssa): Likewise. * bb-reorder.c (bb_to_key): Pass cfun to probably_never_executed_bb_p. (push_to_next_round_p): Likewise. (find_rarely_executed_basic_blocks_and_crossing_edges ): Likewise. * cfg.c: Inlude tree.h. (check_bb_profile): Use profile_status_for_function, EXIT_BLOCK_PTR_FOR_FUNCTION and ENTRY_BLOCK_PTR_FOR_FUNCTION with DECL_STRUCT_FUNCTION (current_function_decl) instead of their cfun variants. (dump_bb_info): Pass DECL_STRUCT_FUNCTION (current_function_decl) to maybe_hot_bb_p and probably_never_executed_bb_p. * gimple-pretty-print.c (gimple_dump_bb_buff): Checking-assert that DECL_STRUCT_FUNCTION (current_function_decl) is not NULL. Pass it to dump_histograms_for_stmt. (dump_gimple_mem_ops): Pass DECL_STRUCT_FUNCTION (current_function_decl) as an argument to dump_gimple_mem_ops. * tree-cfg.c (dump_function_to_file): Rename parameter fn to fndecl. Do not change cfun. Change and restore current_function_decl. * Makefile.in (cfg.o): Include TREE_H in dependencies. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@190645 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index c718cc0a3dc..247f6166a9d 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6632,19 +6632,21 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
*/
void
-dump_function_to_file (tree fn, FILE *file, int flags)
+dump_function_to_file (tree fndecl, FILE *file, int flags)
{
- tree arg, var;
+ tree arg, var, old_current_fndecl = current_function_decl;
struct function *dsf;
bool ignore_topmost_bind = false, any_var = false;
basic_block bb;
tree chain;
- bool tmclone = TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn);
+ bool tmclone = (TREE_CODE (fndecl) == FUNCTION_DECL
+ && decl_is_tm_clone (fndecl));
+ struct function *fun = DECL_STRUCT_FUNCTION (fndecl);
- fprintf (file, "%s %s(", current_function_name (),
- tmclone ? "[tm-clone] " : "");
+ current_function_decl = fndecl;
+ fprintf (file, "%s %s(", function_name (fun), tmclone ? "[tm-clone] " : "");
- arg = DECL_ARGUMENTS (fn);
+ arg = DECL_ARGUMENTS (fndecl);
while (arg)
{
print_generic_expr (file, TREE_TYPE (arg), dump_flags);
@@ -6659,31 +6661,29 @@ dump_function_to_file (tree fn, FILE *file, int flags)
fprintf (file, ")\n");
if (flags & TDF_VERBOSE)
- print_node (file, "", fn, 2);
+ print_node (file, "", fndecl, 2);
- dsf = DECL_STRUCT_FUNCTION (fn);
+ dsf = DECL_STRUCT_FUNCTION (fndecl);
if (dsf && (flags & TDF_EH))
dump_eh_tree (file, dsf);
- if (flags & TDF_RAW && !gimple_has_body_p (fn))
+ if (flags & TDF_RAW && !gimple_has_body_p (fndecl))
{
- dump_node (fn, TDF_SLIM | flags, file);
+ dump_node (fndecl, TDF_SLIM | flags, file);
+ current_function_decl = old_current_fndecl;
return;
}
- /* Switch CFUN to point to FN. */
- push_cfun (DECL_STRUCT_FUNCTION (fn));
-
/* When GIMPLE is lowered, the variables are no longer available in
BIND_EXPRs, so display them separately. */
- if (cfun && cfun->decl == fn && (cfun->curr_properties & PROP_gimple_lcf))
+ if (fun && fun->decl == fndecl && (fun->curr_properties & PROP_gimple_lcf))
{
unsigned ix;
ignore_topmost_bind = true;
fprintf (file, "{\n");
- if (!VEC_empty (tree, cfun->local_decls))
- FOR_EACH_LOCAL_DECL (cfun, ix, var)
+ if (!VEC_empty (tree, fun->local_decls))
+ FOR_EACH_LOCAL_DECL (fun, ix, var)
{
print_generic_decl (file, var, flags);
if (flags & TDF_VERBOSE)
@@ -6709,26 +6709,27 @@ dump_function_to_file (tree fn, FILE *file, int flags)
}
}
- if (cfun && cfun->decl == fn && cfun->cfg && basic_block_info)
+ if (fun && fun->decl == fndecl && fun->cfg
+ && basic_block_info_for_function (fun))
{
/* If the CFG has been built, emit a CFG-based dump. */
if (!ignore_topmost_bind)
fprintf (file, "{\n");
- if (any_var && n_basic_blocks)
+ if (any_var && n_basic_blocks_for_function (fun))
fprintf (file, "\n");
- FOR_EACH_BB (bb)
+ FOR_EACH_BB_FN (bb, fun)
dump_bb (file, bb, 2, flags | TDF_COMMENT);
fprintf (file, "}\n");
}
- else if (DECL_SAVED_TREE (fn) == NULL)
+ else if (DECL_SAVED_TREE (fndecl) == NULL)
{
/* The function is now in GIMPLE form but the CFG has not been
built yet. Emit the single sequence of GIMPLE statements
that make up its body. */
- gimple_seq body = gimple_body (fn);
+ gimple_seq body = gimple_body (fndecl);
if (gimple_seq_first_stmt (body)
&& gimple_seq_first_stmt (body) == gimple_seq_last_stmt (body)
@@ -6751,8 +6752,7 @@ dump_function_to_file (tree fn, FILE *file, int flags)
int indent;
/* Make a tree based dump. */
- chain = DECL_SAVED_TREE (fn);
-
+ chain = DECL_SAVED_TREE (fndecl);
if (chain && TREE_CODE (chain) == BIND_EXPR)
{
if (ignore_topmost_bind)
@@ -6782,11 +6782,9 @@ dump_function_to_file (tree fn, FILE *file, int flags)
dump_enumerated_decls (file, flags);
fprintf (file, "\n\n");
- /* Restore CFUN. */
- pop_cfun ();
+ current_function_decl = old_current_fndecl;
}
-
/* Dump FUNCTION_DECL FN to stderr using FLAGS (see TDF_* in tree.h) */
DEBUG_FUNCTION void