diff options
author | Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> | 2003-10-19 23:37:32 +0200 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2003-10-19 21:37:32 +0000 |
commit | fca9dc00583665bb89e63df672ba2f2184bb9ee6 (patch) | |
tree | c3c61559cf453a985bdb4923c4ed4eae300f5c6d /gcc/toplev.c | |
parent | 47395a24e6a35ef07316b593fb17bf4d767707a7 (diff) | |
download | gcc-fca9dc00583665bb89e63df672ba2f2184bb9ee6.zip gcc-fca9dc00583665bb89e63df672ba2f2184bb9ee6.tar.gz gcc-fca9dc00583665bb89e63df672ba2f2184bb9ee6.tar.bz2 |
Makefile.in (toplev.o): Add value-prof.h dependency.
* Makefile.in (toplev.o): Add value-prof.h dependency.
(value-prof.o): Add REGS_H dependency.
* common.opt (fprofile-values, fvpt): New.
* flags.h (flag_value_profile_transformations): Declare.
* opts.c (common_handle_option): Handle -fprofile_values and
-fvpt.
* profile.c (branch_prob): Don't remove death notes here.
* timevar.def (TV_VPT): New.
* value-prof.c: Include regs.h.
(insn_divmod_values_to_profile, gen_divmod_fixed_value, gen_mod_pow2,
gen_mod_subtract, divmod_fixed_value_transform,mod_pow2_value_transform,
mod_subtract_transform, value_profile_transformations): New.
(insn_values_to_profile): Call insn_divmod_values_to_profile.
(find_values_to_profile): Add dumps.
* value-prof.h (value_profile_transformations): Declare.
* toplev.c: Include value-prof.h.
(rest_of_handle_value_profile_transformations): New.
(enum dump_file_index): Add DFI_vpt.
(dump_file): Add vpt dump.
(flag_value_profile_transformations): New.
(lang_independent_options): Add flag_profile_values and
flag_value_profile_transformations.
(rest_of_compilation): Call
rest_of_handle_value_profile_transformations.
(process_options): Let -fvpt imply -fprofile-values.
* doc/invoke.texi (-fvpt): Document.
From-SVN: r72685
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index c1a05f6..151f6c6 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -78,6 +78,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "cgraph.h" #include "opts.h" #include "coverage.h" +#include "value-prof.h" #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) #include "dwarf2out.h" @@ -137,6 +138,7 @@ static void rest_of_handle_null_pointer (tree, rtx); static void rest_of_handle_addressof (tree, rtx); static void rest_of_handle_cfg (tree, rtx); static void rest_of_handle_branch_prob (tree, rtx); +static void rest_of_handle_value_profile_transformations (tree, rtx); static void rest_of_handle_if_conversion (tree, rtx); static void rest_of_handle_if_after_combine (tree, rtx); static void rest_of_handle_tracer (tree, rtx); @@ -264,6 +266,7 @@ enum dump_file_index DFI_bypass, DFI_cfg, DFI_bp, + DFI_vpt, DFI_ce1, DFI_tracer, DFI_web, @@ -296,7 +299,7 @@ enum dump_file_index Remaining -d letters: " m q " - " JK O Q V Y " + " JK O Q Y " */ static struct dump_file_info dump_file[DFI_MAX] = @@ -318,6 +321,7 @@ static struct dump_file_info dump_file[DFI_MAX] = { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */ { "cfg", 'f', 1, 0, 0 }, { "bp", 'b', 1, 0, 0 }, + { "vpt", 'V', 1, 0, 0 }, { "ce1", 'C', 1, 0, 0 }, { "tracer", 'T', 1, 0, 0 }, { "web", 'Z', 0, 0, 0 }, @@ -404,6 +408,9 @@ int profile_arc_flag = 0; int flag_profile_values = 0; +/* Nonzero if value histograms should be used to optimize code. */ +int flag_value_profile_transformations = 0; + /* Nonzero if generating info for gcov to calculate line test coverage. */ int flag_test_coverage = 0; @@ -1110,6 +1117,8 @@ static const lang_independent_options f_options[] = {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1 }, {"non-call-exceptions", &flag_non_call_exceptions, 1 }, {"profile-arcs", &profile_arc_flag, 1 }, + {"profile-values", &flag_profile_values, 1 }, + {"vpt", &flag_value_profile_transformations, 1 }, {"test-coverage", &flag_test_coverage, 1 }, {"branch-probabilities", &flag_branch_probabilities, 1 }, {"profile", &profile_flag, 1 }, @@ -2462,6 +2471,7 @@ rest_of_handle_branch_prob (tree decl, rtx insns) timevar_push (TV_BRANCH_PROB); open_dump_file (DFI_bp, decl); + if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) branch_prob (); @@ -2481,6 +2491,20 @@ rest_of_handle_branch_prob (tree decl, rtx insns) timevar_pop (TV_BRANCH_PROB); } +/* Do optimizations based on expression value profiles. */ +static void +rest_of_handle_value_profile_transformations (tree decl, rtx insns) +{ + open_dump_file (DFI_vpt, decl); + timevar_push (TV_VPT); + + if (value_profile_transformations ()) + cleanup_cfg (CLEANUP_EXPENSIVE); + + timevar_pop (TV_VPT); + close_dump_file (DFI_vpt, print_rtl_with_bb, insns); +} + /* Do control and data flow analysis; write some of the results to the dump file. */ static void @@ -3345,7 +3369,18 @@ rest_of_compilation (tree decl) if (optimize > 0 || profile_arc_flag || flag_test_coverage || flag_branch_probabilities) - rest_of_handle_branch_prob (decl, insns); + { + rest_of_handle_branch_prob (decl, insns); + + if (flag_branch_probabilities + && flag_profile_values + && flag_value_profile_transformations) + rest_of_handle_value_profile_transformations (decl, insns); + + /* Remove the death notes created for vpt. */ + if (flag_profile_values) + count_or_remove_death_notes (NULL, 1); + } if (optimize > 0) rest_of_handle_if_conversion (decl, insns); @@ -4228,6 +4263,9 @@ process_options (void) if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function) flag_unit_at_a_time = 0; + if (flag_value_profile_transformations) + flag_profile_values = 1; + /* Warn about options that are not supported on this machine. */ #ifndef INSN_SCHEDULING if (flag_schedule_insns || flag_schedule_insns_after_reload) |