> If -fprofile-use is specified, but no .gcda file is found, reset all
> the flags back to the values they would have had if -fprofile-use was
> not specified.  Since the code path where -fprofile-use is on and
> .gcda files are not found is not a well tested pass, this will
> increase the robustness of FDO.  Further, in the event an ICE is found
> when doing FDO, this allows users to delete .gcda files as a work
> around without having to implement complex modifications to the build
> system.  To ensure the testsuite still passes (and is relevant), some
> tests which used -fprofile-use but had no .gcda file had to be moved
> so that they would have a .gcda file generated.  This also involved
> adding a main to these unit tests.
> 
> Bootstrapped and regtested on x86_64.  Ok for trunk?
> 
> 2009-09-29  Neil Vachharajani  <nvach...@google.com>
>       * coverage.c (read_counts_file): Disable profile use if no .gcda
>       file is found.
>       * opts.c (common_handle_option): Call set_profile_use instead of
>       directly setting parameters in -fprofile-use.
>       (set_profile_use): New function.
>       * opts.h (set_profile_use): New function.
>       * testsuite/g++.dg/tree-ssa/dom-invalid.C: Moved to
>       testsuite/g++.dg/tree-prof.
>       * testsuite/g++.dg/tree-prof/dom-invalid.C: See above.
>       * testsuite/gcc.dg/pr26570.c: Moved to
>       testsuite/gcc.dg/tree-prof.
>       * testsuite/gcc.dg/tree-prof/pr26570.c: See above.  main added.
>       * testsuite/gcc.dg/pr32773.c: Moved to
>       testsuite/gcc.dg/tree-prof.
>       * testsuite/gcc.dg/tree-prof/pr32773.c: See above.  main added.
>       

> +
> +/* Set FLAG_PROFILE_USE and dependent flags based on VALUE.  This
> +   function is used to handle the -f(no)profile-use option as well as
> +   to reset flags if a .gcda file is not found.  */
> +
> +void
> +set_profile_use (bool value, bool force)
> +{
> +  flag_profile_use = value;
> +  if (!flag_branch_probabilities_set || force)
> +    flag_branch_probabilities = value;
> +  if (!flag_profile_values_set || force)
> +    flag_profile_values = value;
> +  if (!flag_unroll_loops_set)
> +    flag_unroll_loops = value;
> +  if (!flag_peel_loops_set)
> +    flag_peel_loops = value;
> +  if (!flag_tracer_set)
> +    flag_tracer = value;
> +  if (!flag_value_profile_transformations_set || force)
> +    flag_value_profile_transformations = value;
> +  if (!flag_inline_functions_set)
> +    flag_inline_functions = value;
> +  if (!flag_ipa_cp_set)
> +    flag_ipa_cp = value;
> +  if (!flag_ipa_cp_clone_set)
> +    {
> +      if (!flag_ipa_cp_set || flag_ipa_cp)
> +     flag_ipa_cp_clone = value;
> +    }
> +  if (!flag_predictive_commoning_set)
> +    flag_predictive_commoning = value;
> +  if (!flag_unswitch_loops_set)
> +    flag_unswitch_loops = value;
> +  if (!flag_gcse_after_reload_set)
> +    flag_gcse_after_reload = value;
> +}

It seems to make sense to disable profile feedback when GCDA is missing. 
However I wonder if we can't
figure out before finishing of parsing of flags?
Machine descriptions may want to alter options depending on profile-use so this 
approach seems fragile.

Honza

Reply via email to