This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa]: PATCH: hookize profiling


This is a step towards implementation of tree-based profiling. The existing
coverage.c, profile.c, value-prof.c are changed to handle either RTL or GIMPLE.
New files rtl-profile.c and tree-profile.c separate out some IR-specific pieces,
invoked by hooks. Some additional hooks are added in cfghooks.[ch], cfgrtl.c,
and tree-cfg.c to support this.


There is a new flag, -ftree-based-profiling, that controls which IR is used. If you
don't use this, the behavior is unchanged. The tree-based profiling is rudimentary
as yet; the value-based profiling is not there at all, and the profiling info is lost when
the CFG is destroyed during RTL generation. The tree-based edge profiling will
decorate GIMPLE and read back the profiling data correctly (works for
SPEC, anyway). More work is needed before this is useful (it's coming).


Bootstrapped and tested on Darwin. I've also verified that SPEC works with rtl-based
profiling (-fprofile-arcs/-fbranch-probabilities) as well as before.


Jan Hubicka and Zdenek Dvorak looked over an earlier version of this and commented.
Thanks.


2004-02-11 Dale Johannesen <dalej@apple.com>

* Makefile.in (OBJS-common): Add rtl-profile.o, tree-profile.o.
(rtl-profile.o): New rule.
(tree-profile.o): New rule.
(GTFILES): Add tree-profile.c, rtl-profile.c.
* basic-block.h (flow_call_edges_add): Remove.
* cfganal.c (need_fake_edge_p): Remove.
(flow_call_edges_add): Remove.
* cfghooks.c: Include value-prof.h.
(rtl_register_cfg_hooks): Set up profiling hooks.
(cfg_layout_rtl_register_cfg_hooks): Set up profiling hooks.
(tree_register_cfg_hooks): Set up profiling hooks.
(block_ends_with_call): New.
(block_ends_with_condjump): New.
(flow_call_edges_add): New.
* cfghooks.h: Include value-prof.h.
(struct cfg_hooks): add block_ends_with_call, block_ends_with_condjump,
flow_call_edges_add.
(block_ends_with_call): New declaration.
(block_ends_with_condjump): New declaration.
(flow_call_edges_add): New declaration.
* cfgrtl.c (rtl_block_ends_with_call): New.
(rtl_block_ends_with_condjump): New.
(need_fake_edge_p): New.
(rtl_flow_call_edges_add): New.
(rtl_cfg_hooks): Add rtl_block_ends_with_call,
rtl_block_ends_with_condjump, rtl_flow_call_edges_add.
(cfg_layout_rtl_cfg_hooks): Ditto.
* common.opt (ftree-based-profiling): New.
* coverage.c (tree_ctr_tables): New.
(coverage_counter_alloc): Use it.
(build_ctr_info_value): Ditto.
(coverage_counter_ref): Ditto. Rename to rtl_coverage_counter_ref.
(tree_coverage_counter_ref): New.
* coverage.h (coverage_counter_ref): Remove.
(rtl_coverage_counter_ref): New.
(tree_coverage_counter_ref): New.
* opts.c (OPT_ftree_based_profiling): New.
* profile.c: Include cfghooks.h, tree-flow.h.
(profile_hooks): New.
(profile_dump_file): New.
(instrument_edges): Use hooks instead of RTL-specific code.
(instrument_values): Ditto.
(get_exec_counts): Ditto.
(compute_branch_probabilities): Ditto.
(compute_value_histograms): Ditto.
(branch_prob): Ditto.
(find_spanning_tree): Ditto.
(end_branch_prob): Ditto.
(gen_edge_profiler): Move to rtl-profile.c.
(gen_interval_profiler): Ditto.
(gen_pow2_profiler): Ditto.
(gen_one_value_profiler): Ditto.
(tree_register_profile_hooks): New.
(rtl_register_profile_hooks): New.
* rtl-profile.c: New file.
* rtl.h (init_branch_prob): Remove declaration.
(end_branch_prob): Ditto.
(branch_prob): Ditto.
* toplev.c (flag_tree_based_profiling): New.
(f_options): Add -ftree-based-profiling.
(compile_file): Register rtl-based CFG hooks.
(rest_of_compilation): Do rtl-based profiling only when
!flag_tree_based_profiling.
* toplev.h (flag_tree_based_profiling): New.
* tree-cfg.c (tree_block_ends_with_call): New.
(tree_block_ends_with_condjump): New.
(need_fake_edge_p): New.
(tree_flow_call_edges_add): New.
(tree_cfg_hooks): Add tree_block_ends_with_call,
tree_block_ends_with_condjump, tree_flow_call_edges_add.
* tree-optimize.c (init_tree_optimization_passes):
Add pass_tree_profile.
* tree-pass.h: Ditto.
* tree-profile.c: New file.
* value-prof.c (value_prof_hooks): New.
(find_values_to_profile): Rename to rtl_find_values_to_profile.
Move rtl-specific bits in from branch_prob.
(value_profile_transformations): Rename to
rtl_value_profile_transformations.
(struct value_prof_hooks): New.
(rtl_value_prof_hooks): New.
(rtl_register_value_prof_hooks): New.
(tree_find_values_to_profile): New stub.
(tree_value_profile_transformations): New stub.
(tree_value_prof_hooks): New.
(tree_register_value_prof_hooks): New.
(find_values_to_profile): New.
(value_profile_transformations): New.
* value-prof.h: Add multiple inclusion guard.
(struct histogram_value): Change rtx fields to void *.
(rtl_register_value_prof_hooks): New.
(tree_register_value_prof_hooks): New.
(find_values_to_profile): New.
(free_profiled_values): New.
(value_profile_transformations): New.
(struct profile_hooks): New.
(init_branch_prob): New.
(branch_prob): New.
(end_branch_prob): New.
(tree_register_profile_hooks): New.
(rtl_register_profile_hooks): New.
(tree_profile_hooks): New.
(rtl_profile_hooks): New.
* doc/invoke.texi: Document -ftree-based-profiling.


Attachment: diffs.txt
Description: Text document

Attachment: tree-profile.c
Description: Text document

Attachment: rtl-profile.c
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]