From 84895d28940b46040028e8736adbd83dc2d77b23 Mon Sep 17 00:00:00 2001 From: hubicka Date: Mon, 6 Nov 2017 13:45:41 +0000 Subject: PR bootstrap/82832 * ipa-inline-transform.c (update_noncloned_frequencies): Always scale. (inline_transform): Likewise. * predict.c (counts_to_freqs): Remove useless conditional. * profile-count.h (profile_count::apply_scale): Move sanity check. * tree-inline.c (copy_bb): Always scale. (copy_cfg_body): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254452 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/predict.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/predict.c') diff --git a/gcc/predict.c b/gcc/predict.c index cf42ccbd903..0fd2b72e135 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -3324,8 +3324,7 @@ counts_to_freqs (void) basic_block bb; FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb) - if (!(bb->count < true_count_max)) - true_count_max = true_count_max.max (bb->count); + true_count_max = true_count_max.max (bb->count); cfun->cfg->count_max = true_count_max; -- cgit v1.2.1 From 151b9ff52a095baa99b7cd3f392f82b221d81f98 Mon Sep 17 00:00:00 2001 From: hubicka Date: Fri, 10 Nov 2017 20:14:52 +0000 Subject: * auto-profile.c (afdo_indirect_call): Drop frequency. * cgraph.c (symbol_table::create_edge): Drop frequency argument. (cgraph_node::create_edge): Drop frequency argument. (cgraph_node::create_indirect_edge): Drop frequency argument. (cgraph_edge::make_speculative): Drop frequency arguments. (cgraph_edge::resolve_speculation): Do not update frequencies (cgraph_edge::dump_edge_flags): Do not dump frequency. (cgraph_node::dump): Check consistency in IPA mode. (cgraph_edge::maybe_hot_p): Use IPA counter. (cgraph_edge::verify_count_and_frequency): Rename to ... (cgraph_edge::verify_count): ... this one; drop frequency checking. (cgraph_node::verify_node): Update. * cgraph.h (struct cgraph_edge): Drop frequency. (cgraph_edge::frequency): New function. * cgraphbuild.c (pass_build_cgraph_edges::execute): Donot pass frequencies. (cgraph_edge::rebuild_edges): Likewise. * cgraphclones.c (cgraph_edge::clone): Scale only counts. (duplicate_thunk_for_node): Do not pass frequency. (cgraph_node::create_clone): Scale only counts. (cgraph_node::create_virtual_clone): Do not pass frequency. (cgraph_node::create_edge_including_clones): Do not pass frequency. (cgraph_node::create_version_clone): Do not pass frequency. * cgraphunit.c (cgraph_node::analyze): Do not pass frequency. (cgraph_node::expand_thunk): Do not pass frequency. (cgraph_node::create_wrapper): Do not pass frequency. * gimple-iterator.c (update_call_edge_frequencies): Do not pass frequency. * gimple-streamer-in.c (input_bb): Scale only IPA counts. * ipa-chkp.c (chkp_produce_thunks): Do not pass frequency. * ipa-cp.c (ipcp_lattice::print): Use frequency function. (gather_caller_stats): Use frequency function. (ipcp_cloning_candidate_p): Use frequency function. (ipcp_propagate_stage): Use frequency function. (get_info_about_necessary_edges): Use frequency function. (update_profiling_info): Update only IPA profile. (update_specialized_profile): Use frequency functoin. (perhaps_add_new_callers): Update only IPA profile. * ipa-devirt.c (ipa_devirt): Use IPA profile. * ipa-fnsummary.c (redirect_to_unreachable): Do not set frequrency. (dump_ipa_call_summary): Use frequency function. (estimate_edge_size_and_time): Use frequency function. (ipa_merge_fn_summary_after_inlining): Use frequency function. * ipa-inline-analysis.c (do_estimate_edge_time): Use IPA profile. * ipa-inline-transform.c (update_noncloned_frequencies): Rename to .. (update_noncloned_counts): ... ths one; scale counts only. (clone_inlined_nodes): Do not scale frequency. (inline_call): Do not pass frequency. * ipa-inline.c (compute_uninlined_call_time): Use IPA profile. (compute_inlined_call_time): Use IPA profile. (want_inline_small_function_p): Use IPA profile. (want_inline_self_recursive_call_p): Use IPA profile. (edge_badness): Use IPA profile. (lookup_recursive_calls): Use IPA profile. (recursive_inlining): Do not pass frequency. (resolve_noninline_speculation): Do not update frequency. (inline_small_functions): Collect max of IPA profile. (dump_overall_stats): Dump IPA porfile. (dump_inline_stats): Dump IPA porfile. (ipa_inline): Collect IPA stats. * ipa-inline.h (clone_inlined_nodes): Update prototype. * ipa-profile.c (ipa_propagate_frequency_1): Use frequency function. (ipa_propagate_frequency): Use frequency function. (ipa_profile): Cleanup. * ipa-prop.c (ipa_make_edge_direct_to_target): Do not pass frequency * ipa-utils.c (ipa_merge_profiles): Merge all profiles. * lto-cgraph.c (lto_output_edge): Do not stream frequency. (input_node): Do not stream frequency. (input_edge): Do not stream frequency. (merge_profile_summaries): Scale only IPA profiles. * omp-simd-clone.c (simd_clone_adjust): Do not pass frequency. * predict.c (drop_profile): Do not recompute frequency. * trans-mem.c (ipa_tm_insert_irr_call): Do not pass frequency. (ipa_tm_insert_gettmclone_call): Do not pass frequency. * tree-cfg.c (execute_fixup_cfg): Drop profile to global0 if needed. * tree-chkp.c (chkp_copy_bounds_for_assign): Do not pass frequency. * tree-emutls.c (gen_emutls_addr): Do not pass frequency. * tree-inline.c (copy_bb): Do not scale frequency. (expand_call_inline): Do not scale frequency. (tree_function_versioning): Do not scale frequency. * ubsan.c (ubsan_create_edge): Do not pass frequency. lto/ChangeLog: 2017-11-10 Jan Hubicka * lto-partition.c (lto_balanced_map): Use frequency accessor. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254636 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/predict.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gcc/predict.c') diff --git a/gcc/predict.c b/gcc/predict.c index 0fd2b72e135..07b4bf7c398 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -3222,11 +3222,10 @@ drop_profile (struct cgraph_node *node, profile_count call_count) pop_cfun (); struct cgraph_edge *e; - for (e = node->callees; e; e = e->next_caller) - { - e->frequency = compute_call_stmt_bb_frequency (e->caller->decl, - gimple_bb (e->call_stmt)); - } + for (e = node->callees; e; e = e->next_callee) + e->count = gimple_bb (e->call_stmt)->count; + for (e = node->indirect_calls; e; e = e->next_callee) + e->count = gimple_bb (e->call_stmt)->count; profile_status_for_fn (fn) = (flag_guess_branch_prob ? PROFILE_GUESSED : PROFILE_ABSENT); -- cgit v1.2.1 From b6f13dccc9cd6dce51bae67802f54ccb2c5263b9 Mon Sep 17 00:00:00 2001 From: hubicka Date: Sat, 11 Nov 2017 13:04:25 +0000 Subject: * predict.c (maybe_hot_frequency_p): Do not use cfun. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254652 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/predict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/predict.c') diff --git a/gcc/predict.c b/gcc/predict.c index 07b4bf7c398..56003a5db09 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -137,12 +137,12 @@ maybe_hot_frequency_p (struct function *fun, int freq) if (profile_status_for_fn (fun) == PROFILE_ABSENT) return true; if (node->frequency == NODE_FREQUENCY_EXECUTED_ONCE - && freq < (ENTRY_BLOCK_PTR_FOR_FN (fun)->count.to_frequency (cfun) * 2 / 3)) + && freq < (ENTRY_BLOCK_PTR_FOR_FN (fun)->count.to_frequency (fun) * 2 / 3)) return false; if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0) return false; if (freq * PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) - < ENTRY_BLOCK_PTR_FOR_FN (fun)->count.to_frequency (cfun)) + < ENTRY_BLOCK_PTR_FOR_FN (fun)->count.to_frequency (fun)) return false; return true; } -- cgit v1.2.1 From 688b6bc6943dc52195ca8748fdb741a4ad719bc0 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 14 Nov 2017 09:18:35 +0000 Subject: * auto-profile.c (afdo_annotate_cfg): Use update_max_bb_count. * cgraphunit.c (cgraph_node::expand_thunk): Use update_max_bb_count. * ipa-utils.c (ipa_merge_profiles): Use update_max_bb_count. * lto-streamer-in.c (input_function): Use update_max_bb_count. * omp-expand.c (expand_omp_taskreg): Use update_max_bb_count. * predict.c (maybe_hot_frequency_p): Inline to ... (maybe_hot_count_p): ... here; rewrite to counts. (counts_to_freqs): Rename to ... (update_max_bb_count): ... this one. (expensive_function_p): Use counts. (estimate_bb_frequencies): Update. (rebuild_frequencies): Update. * predict.h (counts_to_freqs): Rename to ... (update_max_bb_count): ... this one. * profile.c (compute_branch_probabilities): Add debug info * tree-inline.c (expand_call_inline): Update debug info. (optimize_inline_calls): Use update_max_bb_count.. (tree_function_versioning): Use update_max_bb_count.. * value-prof.c (gimple_value_profile_transformations): Do not use update_max_bb_count. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254725 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/predict.c | 81 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'gcc/predict.c') diff --git a/gcc/predict.c b/gcc/predict.c index 56003a5db09..f490ec116ad 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -121,32 +121,6 @@ static const struct predictor_info predictor_info[]= { }; #undef DEF_PREDICTOR -/* Return TRUE if frequency FREQ is considered to be hot. */ - -static inline bool -maybe_hot_frequency_p (struct function *fun, int freq) -{ - struct cgraph_node *node = cgraph_node::get (fun->decl); - if (!profile_info || profile_status_for_fn (fun) != PROFILE_READ) - { - if (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED) - return false; - if (node->frequency == NODE_FREQUENCY_HOT) - return true; - } - if (profile_status_for_fn (fun) == PROFILE_ABSENT) - return true; - if (node->frequency == NODE_FREQUENCY_EXECUTED_ONCE - && freq < (ENTRY_BLOCK_PTR_FOR_FN (fun)->count.to_frequency (fun) * 2 / 3)) - return false; - if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0) - return false; - if (freq * PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) - < ENTRY_BLOCK_PTR_FOR_FN (fun)->count.to_frequency (fun)) - return false; - return true; -} - static gcov_type min_count = -1; /* Determine the threshold for hot BB counts. */ @@ -179,10 +153,30 @@ maybe_hot_count_p (struct function *fun, profile_count count) { if (!count.initialized_p ()) return true; - if (!count.ipa_p ()) - return maybe_hot_frequency_p (fun, count.to_frequency (fun)); if (count.ipa () == profile_count::zero ()) return false; + if (!count.ipa_p ()) + { + struct cgraph_node *node = cgraph_node::get (fun->decl); + if (!profile_info || profile_status_for_fn (fun) != PROFILE_READ) + { + if (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED) + return false; + if (node->frequency == NODE_FREQUENCY_HOT) + return true; + } + if (profile_status_for_fn (fun) == PROFILE_ABSENT) + return true; + if (node->frequency == NODE_FREQUENCY_EXECUTED_ONCE + && count < (ENTRY_BLOCK_PTR_FOR_FN (fun)->count.apply_scale (2, 3))) + return false; + if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0) + return false; + if (count.apply_scale (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION), 1) + < ENTRY_BLOCK_PTR_FOR_FN (fun)->count) + return false; + return true; + } /* Code executed at most once is not hot. */ if (count <= MAX (profile_info ? profile_info->runs : 1, 1)) return false; @@ -3317,7 +3311,7 @@ handle_missing_profiles (void) Return nonzero iff there was any nonzero execution count. */ bool -counts_to_freqs (void) +update_max_bb_count (void) { profile_count true_count_max = profile_count::uninitialized (); basic_block bb; @@ -3327,7 +3321,7 @@ counts_to_freqs (void) cfun->cfg->count_max = true_count_max; - return true_count_max.nonzero_p (); + return true_count_max.ipa ().nonzero_p (); } /* Return true if function is likely to be expensive, so there is no point to @@ -3338,30 +3332,37 @@ counts_to_freqs (void) bool expensive_function_p (int threshold) { - unsigned int sum = 0; basic_block bb; - unsigned int limit; /* We can not compute accurately for large thresholds due to scaled frequencies. */ gcc_assert (threshold <= BB_FREQ_MAX); - /* Frequencies are out of range. This either means that function contains - internal loop executing more than BB_FREQ_MAX times or profile feedback - is available and function has not been executed at all. */ - if (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.to_frequency (cfun) == 0) + /* If profile was scaled in a way entry block has count 0, then the function + is deifnitly taking a lot of time. */ + if (!ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.nonzero_p ()) return true; /* Maximally BB_FREQ_MAX^2 so overflow won't happen. */ - limit = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.to_frequency (cfun) * threshold; + profile_count limit = ENTRY_BLOCK_PTR_FOR_FN + (cfun)->count.apply_scale (threshold, 1); + profile_count sum = profile_count::zero (); FOR_EACH_BB_FN (bb, cfun) { rtx_insn *insn; + if (!bb->count.initialized_p ()) + { + if (dump_file) + fprintf (dump_file, "Function is considered expensive because" + " count of bb %i is not initialized\n", bb->index); + return true; + } + FOR_BB_INSNS (bb, insn) if (active_insn_p (insn)) { - sum += bb->count.to_frequency (cfun); + sum += bb->count; if (sum > limit) return true; } @@ -3521,7 +3522,7 @@ estimate_bb_frequencies (bool force) determine_unlikely_bbs (); if (force || profile_status_for_fn (cfun) != PROFILE_READ - || !counts_to_freqs ()) + || !update_max_bb_count ()) { static int real_values_initialized = 0; @@ -3873,7 +3874,7 @@ rebuild_frequencies (void) loop_optimizer_finalize (); } else if (profile_status_for_fn (cfun) == PROFILE_READ) - counts_to_freqs (); + update_max_bb_count (); else gcc_unreachable (); timevar_pop (TV_REBUILD_FREQUENCIES); -- cgit v1.2.1