This patch backports r228136 from trunk to Google/4_9. The only difference is that I have added the option disabling to our Google-specific routine for removing profile options when the specified profile gcda file is not found.
Passes regression tests. Ok for google/4_9? Thanks, Teresa 2015-09-25 Teresa Johnson <tejohn...@google.com> Google ref b/24265250 * opts.c (finish_options): Unset -freorder-blocks-and-partition if not using profile. (set_profile_use_options): Unset -freorder-blocks-and-partition if input profile not found and it wasn't explicitly set. Index: opts.c =================================================================== --- opts.c (revision 228063) +++ opts.c (working copy) @@ -787,6 +787,16 @@ finish_options (struct gcc_options *opts, struct g } if (opts->x_flag_reorder_blocks_and_partition + && !opts_set->x_flag_profile_use) + opts->x_flag_reorder_blocks_and_partition = 0; + + /* Disable -freorder-blocks-and-partition when -fprofile-use is not in + effect. Function splitting was not actually being performed in that case, + as probably_never_executed_bb_p does not distinguish any basic blocks as + being cold vs hot when there is no profile data. Leaving it enabled, + however, causes the assembly code generator to create (empty) cold + sections and labels, leading to unnecessary size overhead. */ + if (opts->x_flag_reorder_blocks_and_partition && !opts_set->x_flag_reorder_functions) opts->x_flag_reorder_functions = 1; @@ -1365,6 +1375,8 @@ set_profile_use_options (struct gcc_options *opts, (PARAM_MAX_INLINE_INSNS_AUTO, default_param_value (PARAM_MAX_INLINE_INSNS_AUTO), opts->x_param_values, opts_set->x_param_values); + if (!opts_set->x_flag_reorder_blocks_and_partition) + opts->x_flag_reorder_blocks_and_partition = false; } if (!opts_set->x_flag_branch_probabilities || reset) -- Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413