This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [GOOGLE] Add flag to enalbe AutoFDO accurate mode
- From: Xinliang David Li <davidxl at google dot com>
- To: Dehao Chen <dehao at google dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 18 Oct 2013 08:41:53 -0700
- Subject: Re: [GOOGLE] Add flag to enalbe AutoFDO accurate mode
- Authentication-results: sourceware.org; auth=none
- References: <CAO2gOZVs-YERrXhJYgWUe-2+xDZeCH56kAH8yak_SMJfJbb=TQ at mail dot gmail dot com>
ok.
David
On Tue, Oct 15, 2013 at 10:58 AM, Dehao Chen <dehao@google.com> wrote:
> This patch add a new flag to let user to tell compiler that the
> AutoFDO profile is accurate. So the compiler will assume function
> without any sample is UNLIKELY_EXECUTED. This could save 10%~20% text
> section size.
>
> Bootstrapped and passed regression test.
>
> OK for google-4_8 branch?
>
> Thanks,
> Dehao
>
> Index: gcc/common.opt
> ===================================================================
> --- gcc/common.opt (revision 203546)
> +++ gcc/common.opt (working copy)
> @@ -942,6 +942,10 @@ Common Joined RejectNegative Var(auto_profile_file
> Use sample profile information for call graph node weights. The profile
> file is specified in the argument.
>
> +fauto-profile-accurate
> +Common Report Var(flag_auto_profile_accurate) Optimization
> +Whether to assume the sample profile is accurate.
> +
> ; -fcheck-bounds causes gcc to generate array bounds checks.
> ; For C, C++ and ObjC: defaults off.
> ; For Java: defaults to on.
> Index: gcc/predict.c
> ===================================================================
> --- gcc/predict.c (revision 203546)
> +++ gcc/predict.c (working copy)
> @@ -2866,7 +2866,9 @@ compute_function_frequency (void)
> || (flag_auto_profile && profile_status == PROFILE_GUESSED))
> {
> int flags = flags_from_decl_or_type (current_function_decl);
> - if (lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl))
> + if (profile_info && flag_auto_profile_accurate)
> + node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
> + else if (lookup_attribute ("cold", DECL_ATTRIBUTES
> (current_function_decl))
> != NULL)
> node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
> else if (lookup_attribute ("hot", DECL_ATTRIBUTES
> (current_function_decl))