diff options
author | Jan Hubicka <jh@suse.cz> | 2023-07-14 17:14:15 +0200 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2023-07-14 17:14:15 +0200 |
commit | aa6741ef2e0c312af51825f6411380fe160a8222 (patch) | |
tree | 69463ab8f0068daa77098600efe986020976aa3a /gcc/passes.def | |
parent | 0d2673e995f0dd69f406a34d2e87d2a25cf3c285 (diff) | |
download | gcc-aa6741ef2e0c312af51825f6411380fe160a8222.zip gcc-aa6741ef2e0c312af51825f6411380fe160a8222.tar.gz gcc-aa6741ef2e0c312af51825f6411380fe160a8222.tar.bz2 |
Turn TODO_rebuild_frequencies to a pass
Currently we rebiuild profile_counts from profile_probability after inlining,
because there is a chance that producing large loop nests may get unrealistically
large profile_count values. This is much less of concern when we switched to
new profile_count representation while back.
This propagation can also compensate for profile inconsistencies caused by
optimization passes. Since inliner is followed by basic cleanup passes that
does not use profile, we get more realistic profile by delaying the recomputation
after basic optimizations exposed by inlininig are finished.
This does not fit into TODO machinery, so I turn rebuilding into stand alone
pass and schedule it before first consumer of profile in the optimization
queue.
I also added logic that avoids repropagating when CFG is good and not too close
to overflow. Propagating visits very basic block loop_depth times, so it is
not linear and avoiding it may help a bit.
On tramp3d we get 14 functions repropagated and 916 are OK. The repropagated
functions are RB tree ones where we produce crazy loop nests by recurisve inlining.
This is something to fix independently.
gcc/ChangeLog:
* passes.cc (execute_function_todo): Remove
TODO_rebuild_frequencies
* passes.def: Add rebuild_frequencies pass.
* predict.cc (estimate_bb_frequencies): Drop
force parameter.
(tree_estimate_probability): Update call of
estimate_bb_frequencies.
(rebuild_frequencies): Turn into a pass; verify CFG profile consistency
first and do not rebuild if not necessary.
(class pass_rebuild_frequencies): New.
(make_pass_rebuild_frequencies): New.
* profile-count.h: Add profile_count::very_large_p.
* tree-inline.cc (optimize_inline_calls): Do not return
TODO_rebuild_frequencies
* tree-pass.h (TODO_rebuild_frequencies): Remove.
(make_pass_rebuild_frequencies): Declare.
Diffstat (limited to 'gcc/passes.def')
-rw-r--r-- | gcc/passes.def | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/passes.def b/gcc/passes.def index faa5208..f2893ae 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -206,6 +206,10 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_post_ipa_warn); /* Must run before loop unrolling. */ NEXT_PASS (pass_warn_access, /*early=*/true); + /* Profile count may overflow as a result of inlinining very large + loop nests. This pass should run before any late pass that makes + use of profile. */ + NEXT_PASS (pass_rebuild_frequencies); NEXT_PASS (pass_complete_unrolli); NEXT_PASS (pass_backprop); NEXT_PASS (pass_phiprop); @@ -395,6 +399,10 @@ along with GCC; see the file COPYING3. If not see to forward object-size and builtin folding results properly. */ NEXT_PASS (pass_copy_prop); NEXT_PASS (pass_dce); + /* Profile count may overflow as a result of inlinining very large + loop nests. This pass should run before any late pass that makes + use of profile. */ + NEXT_PASS (pass_rebuild_frequencies); NEXT_PASS (pass_sancov); NEXT_PASS (pass_asan); NEXT_PASS (pass_tsan); |