diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2019-12-05 19:12:51 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2019-12-05 18:12:51 +0000 |
commit | 34fbe3f0946f88828765184ed6581bda62cdf49f (patch) | |
tree | 5a3bf82ae6bb92203c6e4922a5d694198595edc6 /gcc/profile.c | |
parent | 8575d5925226a8f92ee644d6d59a2b1b93840d94 (diff) | |
download | gcc-34fbe3f0946f88828765184ed6581bda62cdf49f.zip gcc-34fbe3f0946f88828765184ed6581bda62cdf49f.tar.gz gcc-34fbe3f0946f88828765184ed6581bda62cdf49f.tar.bz2 |
cgraphclones.c (localize_profile): New function.
* cgraphclones.c (localize_profile): New function.
(cgraph_node::create_clone): Use it for partial profiles.
* common.opt (fprofile-partial-training): New flag.
* doc/invoke.texi (-fprofile-partial-training): Document.
* ipa-cp.c (update_profiling_info): For partial profiles do not
set function profile to zero.
* profile.c (compute_branch_probabilities): With partial profile
watch if edge count is zero and turn all probabilities to guessed.
(compute_branch_probabilities): For partial profiles do not apply
profile when entry count is zero.
* tree-profile.c (tree_profiling): Only do value_profile_transformations
when profile is read.
From-SVN: r279013
Diffstat (limited to 'gcc/profile.c')
-rw-r--r-- | gcc/profile.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/gcc/profile.c b/gcc/profile.c index 8d39a7d..7e2d7d3 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -635,9 +635,20 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum) } if (bb_gcov_count (bb)) { + bool set_to_guessed = false; FOR_EACH_EDGE (e, ei, bb->succs) - e->probability = profile_probability::probability_in_gcov_type - (edge_gcov_count (e), bb_gcov_count (bb)); + { + bool prev_never = e->probability == profile_probability::never (); + e->probability = profile_probability::probability_in_gcov_type + (edge_gcov_count (e), bb_gcov_count (bb)); + if (e->probability == profile_probability::never () + && !prev_never + && flag_profile_partial_training) + set_to_guessed = true; + } + if (set_to_guessed) + FOR_EACH_EDGE (e, ei, bb->succs) + e->probability = e->probability.guessed (); if (bb->index >= NUM_FIXED_BLOCKS && block_ends_with_condjump_p (bb) && EDGE_COUNT (bb->succs) >= 2) @@ -697,17 +708,23 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum) } } - if (exec_counts) + if (exec_counts + && (bb_gcov_count (ENTRY_BLOCK_PTR_FOR_FN (cfun)) + || !flag_profile_partial_training)) profile_status_for_fn (cfun) = PROFILE_READ; /* If we have real data, use them! */ if (bb_gcov_count (ENTRY_BLOCK_PTR_FOR_FN (cfun)) || !flag_guess_branch_prob) FOR_ALL_BB_FN (bb, cfun) - bb->count = profile_count::from_gcov_type (bb_gcov_count (bb)); + if (bb_gcov_count (bb) || !flag_profile_partial_training) + bb->count = profile_count::from_gcov_type (bb_gcov_count (bb)); + else + bb->count = profile_count::guessed_zero (); /* If function was not trained, preserve local estimates including statically determined zero counts. */ - else if (profile_status_for_fn (cfun) == PROFILE_READ) + else if (profile_status_for_fn (cfun) == PROFILE_READ + && !flag_profile_partial_training) FOR_ALL_BB_FN (bb, cfun) if (!(bb->count == profile_count::zero ())) bb->count = bb->count.global0 (); @@ -1417,7 +1434,7 @@ branch_prob (bool thunk) /* At this moment we have precise loop iteration count estimates. Record them to loop structure before the profile gets out of date. */ FOR_EACH_LOOP (loop, 0) - if (loop->header->count > 0) + if (loop->header->count > 0 && loop->header->count.reliable_p ()) { gcov_type nit = expected_loop_iterations_unbounded (loop); widest_int bound = gcov_type_to_wide_int (nit); |