diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2004-09-06 10:08:17 +0000 |
---|---|---|
committer | Paolo Bonzini <bonzini@gcc.gnu.org> | 2004-09-06 10:08:17 +0000 |
commit | 9f8628bacdb26f5c6f63aa305f29212b0d766199 (patch) | |
tree | 97abeef925c810d92e8f8fe91a694ecb3c7ca58b /gcc/tree-optimize.c | |
parent | fc4d0e828dfb1126ad2a7803cd68d655915c8bfa (diff) | |
download | gcc-9f8628bacdb26f5c6f63aa305f29212b0d766199.zip gcc-9f8628bacdb26f5c6f63aa305f29212b0d766199.tar.gz gcc-9f8628bacdb26f5c6f63aa305f29212b0d766199.tar.bz2 |
Unify the management of RTL and tree-level dump files.
2004-09-06 Paolo Bonzini <bonzini@gnu.org>
Unify the management of RTL and tree-level dump files.
* cfgexpand.c (tree_expand_cfg): Fix incorrect comment.
Don't print function name to the dump file, the pass manager
would do this for us. Add code from the top of
rest_of_compilation, up to the initial RTL dump.
* passes.c (rest_of_handle_jump): Call fixup_tail_calls and
close the DFI_sibling dump file.
(rest_of_compilation): Don't do that here. Remove code up to the
initial RTL dump.
(init_optimization_passes): Remove.
(pass_rest_of_compilation): Change pass name to NULL.
* toplev.c (lang_dependent_init): Do not use an empty dump file prefix.
Do not call init_optimization_passes.
* toplev.h (init_optimization_passes): Remove.
* graph.c (print_rtl_graph_with_bb, clean_graph_dump_file,
finish_graph_dump_file): Remove SUFFIX parameter.
* graph.h (print_rtl_graph_with_bb, clean_graph_dump_file,
finish_graph_dump_file): Likewise.
* tree-pass.h (struct tree_opt_pass): Add `letter' field.
* cfgexpand.c (pass_expand): Adjust.
* gimple-low.c (pass_lower_cf, pass_remove_useless_vars): Adjust.
* passes.c (pass_rest_of_compilation): Adjust.
* predict.c (pass_profile): Adjust.
* tree-alias-common.c (pass_build_pta, pass_del_pta): Adjust.
* tree-cfg.c (pass_build_cfg, pass_remove_useless_stmts,
pass_split_crit_edges, pass_warn_function_return): Adjust.
* tree-complex.c (pass_lower_vector_ssa, pass_pre_expand): Adjust.
* tree-dfa.c (pass_referenced_vars): Adjust.
* tree-eh.c (pass_lower_eh): Adjust.
* tree-if-conv.c (pass_build_ssa): Adjust.
* tree-into-ssa.c (pass_build_ssa): Adjust.
* tree-mudflap.c (pass_mudflap_1, pass_mudflap_2): Adjust.
* tree-nomudflap.c (pass_mudflap_1, pass_mudflap_2): Adjust.
* tree-nrv.c (pass_nrv): Adjust.
* tree-optimize.c (pass_gimple, pass_all_optimizations,
pass_cleanup_cfg_post_optimizing, pass_free_datastructures,
pass_init_datastructures): Adjust.
* tree-outof-ssa.c (pass_del_ssa): Adjust.
* tree-profile.c (pass_tree_profile): Adjust.
* tree-sra.c (pass_sra): Adjust.
* tree-ssa-alias.c (pass_may_alias): Adjust.
* tree-ssa-ccp.c (pass_ccp, pass_fold_builtins): Adjust.
* tree-ssa-copyrename.c (pass_rename_ssa_copies): Adjust.
* tree-ssa-dce.c (pass_dce, pass_cd_dce): Adjust.
* tree-ssa-dom.c (pass_dominator): Adjust.
* tree-ssa-dse.c (pass_dse): Adjust.
* tree-ssa-forwprop.c (pass_forwprop): Adjust.
* tree-ssa-if-conv.c (pass_if_conversion): Adjust.
* tree-ssa-loop-ch.c (pass_ch): Adjust.
* tree-ssa-loop.c (pass_loop, pass_loop_init, pass_lim,
pass_loop_done, pass_complete_unroll, pass_iv_canon,
pass_iv_optimize, pass_vectorize): Adjust.
* tree-ssa-phiopt.c (pass_phiopt): Adjust.
* tree-ssa-pre.c (pass_pre, pass_fre): Adjust.
* tree-ssa.c (pass_redundant_phi, pass_early_warn_uninitialized,
pass_late_warn_uninnitialized): Adjust.
* tree-tailcall.c (pass_tail_recursion, pass_tail_calls): Adjust.
* Makefile.in (tree-dump.o): Add new dependencies.
* cgraph.c (cgraph_remove_node): TDF_all -> TDF_tree_all.
* cgraphunit.c (cgraph_preserve_function_body_p, cgraph_optimize):
Likewise.
* toplev.c (dump_file_name): New.
* tree-dump.c (dump_enable_all): Add LETTER parameter.
(struct dump_file_info): Add NUM and LETTER fields.
(dump_files): Adjust and add RTL dump files.
(dump_register): Add NUM and LETTER fields.
(get_dump_file_name, dump_initialized_p, enable_rtl_dump_file): New.
(dump_begin): Use get_dump_file_name.
(dump_switch_p_1): Adjust call to dump_enable_all.
* tree-dump.h (dump_register): Adjust prototype.
* tree-optimize.c (register_one_dump_file): Take dump file index.
Support flags for RTL dumps.
(register_dump_files): Fill in NUM field of struct dump_file_info.
Track properties both when the gate is executed and when it is not.
(execute_todo): Dump RTL. Add PROPERTIES parameter.
(execute_one_pass): Pass properties to execute_todo. Handle VCG
dumps of RTL.
* tree-pass.h (dump_file_name): New.
* tree.h (TDF_TREE, TDF_RTL, get_dump_file_name, dump_initialized_p):
New.
* Makefile.in (passes.o): Add new dependencies.
* passes.c (struct dump_file_info, enum dump_file_index,
dump_file_tbl, init_optimization_passes): Remove.
(open_dump_file, close_dump_file): Use tree-dumping infrastructure.
(rest_of_handle_new_regalloc, rest_of_handle_old_regalloc): Use
dump_enabled_p.
(finish_optimization_passes): Update finish_graph_dump_file loop.
(enable_rtl_dump_file): Remove.
* tree-dump.c (dump_files): Adjust and add RTL dump files.
(enable_rtl_dump_file): Add here.
* tree.h (enum tree_dump_index): Add RTL dump file indices.
* doc/invoke.texi (Debugging options): Document new RTL debugging
options. Update.
From-SVN: r87113
Diffstat (limited to 'gcc/tree-optimize.c')
-rw-r--r-- | gcc/tree-optimize.c | 111 |
1 files changed, 83 insertions, 28 deletions
diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index 71b66c8..701b104 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -47,6 +47,7 @@ Boston, MA 02111-1307, USA. */ #include "tree-alias-common.h" #include "ggc.h" #include "cgraph.h" +#include "graph.h" /* Global variables used to communicate with passes. */ @@ -72,7 +73,8 @@ static struct tree_opt_pass pass_gimple = PROP_gimple_any, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - TODO_dump_func /* todo_flags_finish */ + TODO_dump_func, /* todo_flags_finish */ + 0 /* letter */ }; /* Gate: execute, or not, all of the non-trivial optimizations. */ @@ -98,7 +100,8 @@ static struct tree_opt_pass pass_all_optimizations = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ + 0, /* todo_flags_finish */ + 0 /* letter */ }; /* Pass: cleanup the CFG just before expanding trees to RTL. @@ -127,7 +130,8 @@ static struct tree_opt_pass pass_cleanup_cfg_post_optimizing = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ + 0, /* todo_flags_finish */ + 0 /* letter */ }; /* Pass: do the actions required to finish with tree-ssa optimization @@ -170,7 +174,8 @@ static struct tree_opt_pass pass_free_datastructures = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ + 0, /* todo_flags_finish */ + 0 /* letter */ }; @@ -197,7 +202,8 @@ static struct tree_opt_pass pass_init_datastructures = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ + 0, /* todo_flags_finish */ + 0 /* letter */ }; /* Iterate over the pass tree allocating dump file numbers. We want @@ -205,14 +211,11 @@ static struct tree_opt_pass pass_init_datastructures = enabled or not. */ static void -register_one_dump_file (struct tree_opt_pass *pass) +register_one_dump_file (struct tree_opt_pass *pass, int n) { char *dot_name, *flag_name; char num[10]; - if (!pass->name) - return; - /* See below in next_pass_1. */ num[0] = '\0'; if (pass->static_pass_number != -1) @@ -220,31 +223,55 @@ register_one_dump_file (struct tree_opt_pass *pass) ? 1 : pass->static_pass_number)); dot_name = concat (".", pass->name, num, NULL); - flag_name = concat ("tree-", pass->name, num, NULL); - - pass->static_pass_number = dump_register (dot_name, flag_name); + if (pass->properties_provided & PROP_trees) + { + flag_name = concat ("tree-", pass->name, num, NULL); + pass->static_pass_number = dump_register (dot_name, flag_name, + TDF_TREE, n + TDI_tree_all, 0); + } + else + { + flag_name = concat ("rtl-", pass->name, num, NULL); + pass->static_pass_number = dump_register (dot_name, flag_name, + TDF_RTL, n, pass->letter); + } } static int register_dump_files (struct tree_opt_pass *pass, int properties) { + static int n = 0; do { - /* Verify that all required properties are present. */ - if (pass->properties_required & ~properties) - abort (); - - if (pass->properties_destroyed & pass->properties_provided) - abort (); + int new_properties; + int pass_number; pass->properties_required = properties; - pass->properties_provided = properties = + new_properties = (properties | pass->properties_provided) & ~pass->properties_destroyed; - if (properties & PROP_trees) - register_one_dump_file (pass); + /* Reset the counter when we reach RTL-based passes. */ + if ((pass->properties_provided ^ pass->properties_required) & PROP_rtl) + n = 0; + + pass_number = n; + if (pass->name) + n++; + if (pass->sub) - properties = register_dump_files (pass->sub, properties); + new_properties = register_dump_files (pass->sub, new_properties); + + /* If we have a gate, combine the properties that we could have with + and without the pass being examined. */ + if (pass->gate) + properties &= new_properties; + else + properties = new_properties; + + pass->properties_provided = properties; + if (pass->name) + register_one_dump_file (pass, pass_number); + pass = pass->next; } while (pass); @@ -386,7 +413,7 @@ static void execute_pass_list (struct tree_opt_pass *); static unsigned int last_verified; static void -execute_todo (unsigned int flags) +execute_todo (int properties, unsigned int flags) { if (flags & TODO_rename_vars) { @@ -396,8 +423,13 @@ execute_todo (unsigned int flags) if ((flags & TODO_dump_func) && dump_file) { - dump_function_to_file (current_function_decl, - dump_file, dump_flags); + if (properties & PROP_trees) + dump_function_to_file (current_function_decl, + dump_file, dump_flags); + else if (properties & PROP_cfg) + print_rtl_with_bb (dump_file, get_insns ()); + else + print_rtl (dump_file, get_insns ()); /* Flush the file. If verification fails, we won't be able to close the file before aborting. */ @@ -433,11 +465,13 @@ execute_one_pass (struct tree_opt_pass *pass) /* Run pre-pass verification. */ todo = pass->todo_flags_start & ~last_verified; if (todo) - execute_todo (todo); + execute_todo (pass->properties_required, todo); /* If a dump file name is present, open it if enabled. */ if (pass->static_pass_number != -1) { + bool initializing_dump = !dump_initialized_p (pass->static_pass_number); + dump_file_name = get_dump_file_name (pass->static_pass_number); dump_file = dump_begin (pass->static_pass_number, &dump_flags); if (dump_file) { @@ -445,8 +479,19 @@ execute_one_pass (struct tree_opt_pass *pass) dname = lang_hooks.decl_printable_name (current_function_decl, 2); aname = (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); - fprintf (dump_file, "\n;; Function %s (%s)\n\n", dname, aname); + fprintf (dump_file, "\n;; Function %s (%s)%s\n\n", dname, aname, + cfun->function_frequency == FUNCTION_FREQUENCY_HOT + ? " (hot)" + : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED + ? " (unlikely executed)" + : ""); } + + if (initializing_dump + && graph_dump_format != no_graph + && (pass->properties_provided & (PROP_cfg | PROP_rtl)) + == (PROP_cfg | PROP_rtl)) + clean_graph_dump_file (dump_file_name); } /* If a timevar is present, start it. */ @@ -457,15 +502,25 @@ execute_one_pass (struct tree_opt_pass *pass) if (pass->execute) pass->execute (); + if (dump_file + && (pass->properties_provided & (PROP_cfg | PROP_rtl)) + == (PROP_cfg | PROP_rtl)) + print_rtl_graph_with_bb (dump_file_name, get_insns ()); + /* Run post-pass cleanup and verification. */ todo = pass->todo_flags_finish; last_verified = todo & TODO_verify_all; if (todo) - execute_todo (todo); + execute_todo (pass->properties_provided, todo); /* Close down timevar and dump file. */ if (pass->tv_id) timevar_pop (pass->tv_id); + if (dump_file_name) + { + free ((char *) dump_file_name); + dump_file_name = NULL; + } if (dump_file) { dump_end (pass->static_pass_number, dump_file); |