This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] decide edge's hotness when there is profile info
- From: Steven Bosscher <stevenb dot gcc at gmail dot com>
- To: Teresa Johnson <tejohnson at google dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Dehao Chen <dehao at google dot com>, Xinliang David Li <davidxl at google dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 8 Nov 2013 23:14:31 +0100
- Subject: Re: [PATCH] decide edge's hotness when there is profile info
- Authentication-results: sourceware.org; auth=none
- References: <CAAe5K+VJ70+Sj_J-uwcr+W6THPZXe5cy-hwtBCpJXms2=nPimg at mail dot gmail dot com> <CAO2gOZVmMLBEnEYdh4yFD8D5y0netp8V0VLNW1Wcwt9fcwEYkw at mail dot gmail dot com> <CAAe5K+V5k2i9gpo0Ak8b5MnC87uSeaJWJzkRUrZxtoF1M8crNg at mail dot gmail dot com> <CAO2gOZV-opRL_R-1sVQD8BdMaUDHac3H+WfF8Y-vkdHzRd__Sg at mail dot gmail dot com> <20131015210324 dot GA23980 at kam dot mff dot cuni dot cz> <CAAe5K+X8MzvUHdpGVG5jKpz35XpjnPLig--eaHWG9pCNFdS3Bw at mail dot gmail dot com> <20131015215741 dot GA22365 at kam dot mff dot cuni dot cz> <CAAe5K+V+Yidij=WZM=rwfqfewuh81UOcUvHKVwT_g-9YwpUs-A at mail dot gmail dot com> <CAAe5K+Vw8YbvEe+qSKF8js_TgCEehdJ-qKVD2HkFS0pBRF+e+g at mail dot gmail dot com> <CAAe5K+XHKWOkZEaavJkFEfhWME4qKg_ByuXSrzxhKjgCu-QpWQ at mail dot gmail dot com> <20131018211757 dot GB31793 at kam dot mff dot cuni dot cz> <CAAe5K+XKp_5eBhEXxF29OmdrRv9nyr+aXW+PCdGH4hsFGY0X3w at mail dot gmail dot com> <CAAe5K+WZ2=YavTXf3yzdRHOmO9rEhvUM6xpDUKiRhkGhbX6JBQ at mail dot gmail dot com> <CAAe5K+UOn4wxvwsGhy_EjiFFQMDB-emRbpNJkY5bBf6QgRJo4w at mail dot gmail dot com>
On Fri, Nov 8, 2013 at 10:58 PM, Teresa Johnson wrote:
> +static void
> +drop_profile (struct cgraph_node *node, bool hot)
> +{
> + struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
> +
> + if (dump_file)
> + fprintf (dump_file,
> + "Dropping 0 profile for %s/%i. %s based on calls.\n",
> + cgraph_node_name (node), node->order,
> + hot ? "Function is hot" : "Function is normal");
> + /* We only expect to miss profiles for functions that are reached
> + via non-zero call edges in cases where the function may have
> + been linked from another module or library (COMDATs and extern
> + templates). See the comments below for handle_missing_profiles. */
> + if (!DECL_COMDAT (node->decl) && !DECL_EXTERNAL (node->decl))
> + warning (0,
> + "Missing counts for called function %s/%i",
> + cgraph_node_name (node), node->order);
Maybe OPT_Wdisabled_optimization?
> +
> + profile_status_for_function (fn)
> + = (flag_guess_branch_prob ? PROFILE_GUESSED : PROFILE_ABSENT);
> + node->frequency
> + = hot ? NODE_FREQUENCY_HOT : NODE_FREQUENCY_NORMAL;
In GCC code style the = goes at the end of the line:
profile_status_for_function (fn)
(flag_guess_branch_prob ? PROFILE_GUESSED : PROFILE_ABSENT);
node->frequency =
hot ? NODE_FREQUENCY_HOT : NODE_FREQUENCY_NORMAL;
> @@ -2774,6 +2875,9 @@ counts_to_freqs (void)
> gcov_type count_max, true_count_max = 0;
> basic_block bb;
>
> + if (!ENTRY_BLOCK_PTR->count)
> + return 0;
> +
Deserves a one-line comment ;-)
> +void
> +freqs_to_counts (struct cgraph_node *node, gcov_type count)
> +{
> + basic_block bb;
> + edge_iterator ei;
> + edge e;
> + struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
> +
> + FOR_ALL_BB_FN(bb, fn)
> + {
> + bb->count = apply_scale (count,
> + GCOV_COMPUTE_SCALE (bb->frequency, BB_FREQ_MAX));
> + FOR_EACH_EDGE (e, ei, bb->succs)
> + e->count = apply_probability (e->src->count, e->probability);
> + }
Indent +2:
FOR_ALL_BB_FN (bb, fn)
{
...
}
Ciao!
Steven