Add AutoFDO.
gcc/ChangeLog: 2014-10-21 Dehao Chen <dehao@google.com> * auto-profile.c: New file. * auto-profile.h: New file. * basic-block.h (maybe_hot_count_p): New export func. (add_working_set): New export func. * gcov-io.h (GCOV_TAG_AFDO_FILE_NAMES): New tag. (GCOV_TAG_AFDO_FUNCTION): Likewise. (GCOV_TAG_AFDO_WORKING_SET): Likewise. * opts.c (enable_fdo_optimizations): New func. (common_handle_option): Handle -fauto-profile flag. * ipa-inline.c (want_early_inline_function_p): Iterative-einline. (class pass_early_inline): Export early_inliner. (early_inliner): Likewise. (pass_early_inline::execute): Likewise. * ipa-inline.h (early_inliner): Likewise. * predict.c (maybe_hot_count_p): New export func. (counts_to_freqs): AutoFDO logic. (rebuild_frequencies): Likewise. * tree-profile.c (pass_ipa_tree_profile::gate): Likewise. * profile.c (add_working_set): New func. * Makefile.in (auto-profile.o): New object file. * passes.def (pass_ipa_auto_profile): New pass. * tree-ssa-live.c (remove_unused_scope_block_p): AutoFDO logic. * tree-pass.h (make_pass_ipa_auto_profile): New pass. * toplev.c (compile_file): AutoFDO logic. * doc/invoke.texi (-fauto-profile): New doc. * coverage.c (coverage_init): AutoFDO logic. * common.opt (-fauto-profile): New flag. * timevar.def (TV_IPA_AUTOFDO): New tag. * value-prof.c (gimple_alloc_histogram_value): New export func. (check_ic_target): Likewise. * value-prof.h (gimple_alloc_histogram_value): Likewise. (check_ic_target): Likewise. From-SVN: r216523
This commit is contained in:
parent
3edf64aa91
commit
be3c16c474
22 changed files with 1950 additions and 80 deletions
|
@ -1,3 +1,38 @@
|
|||
2014-10-21 Dehao Chen <dehao@google.com>
|
||||
|
||||
* auto-profile.c: New file.
|
||||
* auto-profile.h: New file.
|
||||
* basic-block.h (maybe_hot_count_p): New export func.
|
||||
(add_working_set): New export func.
|
||||
* gcov-io.h (GCOV_TAG_AFDO_FILE_NAMES): New tag.
|
||||
(GCOV_TAG_AFDO_FUNCTION): Likewise.
|
||||
(GCOV_TAG_AFDO_WORKING_SET): Likewise.
|
||||
* opts.c (enable_fdo_optimizations): New func.
|
||||
(common_handle_option): Handle -fauto-profile flag.
|
||||
* ipa-inline.c (want_early_inline_function_p): Iterative-einline.
|
||||
(class pass_early_inline): Export early_inliner.
|
||||
(early_inliner): Likewise.
|
||||
(pass_early_inline::execute): Likewise.
|
||||
* ipa-inline.h (early_inliner): Likewise.
|
||||
* predict.c (maybe_hot_count_p): New export func.
|
||||
(counts_to_freqs): AutoFDO logic.
|
||||
(rebuild_frequencies): Likewise.
|
||||
* tree-profile.c (pass_ipa_tree_profile::gate): Likewise.
|
||||
* profile.c (add_working_set): New func.
|
||||
* Makefile.in (auto-profile.o): New object file.
|
||||
* passes.def (pass_ipa_auto_profile): New pass.
|
||||
* tree-ssa-live.c (remove_unused_scope_block_p): AutoFDO logic.
|
||||
* tree-pass.h (make_pass_ipa_auto_profile): New pass.
|
||||
* toplev.c (compile_file): AutoFDO logic.
|
||||
* doc/invoke.texi (-fauto-profile): New doc.
|
||||
* coverage.c (coverage_init): AutoFDO logic.
|
||||
* common.opt (-fauto-profile): New flag.
|
||||
* timevar.def (TV_IPA_AUTOFDO): New tag.
|
||||
* value-prof.c (gimple_alloc_histogram_value): New export func.
|
||||
(check_ic_target): Likewise.
|
||||
* value-prof.h (gimple_alloc_histogram_value): Likewise.
|
||||
(check_ic_target): Likewise.
|
||||
|
||||
2014-10-21 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* cgraph.c (cgraph_c_finalize): New function.
|
||||
|
|
|
@ -1153,6 +1153,7 @@ OBJS = \
|
|||
alias.o \
|
||||
alloc-pool.o \
|
||||
auto-inc-dec.o \
|
||||
auto-profile.o \
|
||||
bb-reorder.o \
|
||||
bitmap.o \
|
||||
bt-load.o \
|
||||
|
|
1687
gcc/auto-profile.c
Normal file
1687
gcc/auto-profile.c
Normal file
File diff suppressed because it is too large
Load diff
31
gcc/auto-profile.h
Normal file
31
gcc/auto-profile.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* auto-profile.h - Defines data exported from auto-profile.c
|
||||
Copyright (C) 2014. Free Software Foundation, Inc.
|
||||
Contributed by Dehao Chen (dehao@google.com)
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 3, or (at your option) any later
|
||||
version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef AUTO_PROFILE_H
|
||||
#define AUTO_PROFILE_H
|
||||
|
||||
/* Read, process, finalize AutoFDO data structures. */
|
||||
extern void read_autofdo_file (void);
|
||||
extern void end_auto_profile (void);
|
||||
|
||||
/* Returns TRUE if EDGE is hot enough to be inlined early. */
|
||||
extern bool afdo_callsite_hot_enough_for_early_inline (struct cgraph_edge *);
|
||||
|
||||
#endif /* AUTO_PROFILE_H */
|
|
@ -652,6 +652,7 @@ ei_cond (edge_iterator ei, edge *p)
|
|||
extern void dump_flow_info (FILE *, int);
|
||||
|
||||
/* In predict.c */
|
||||
extern bool maybe_hot_count_p (struct function *, gcov_type);
|
||||
extern bool maybe_hot_bb_p (struct function *, const_basic_block);
|
||||
extern bool maybe_hot_edge_p (edge);
|
||||
extern bool probably_never_executed_bb_p (struct function *, const_basic_block);
|
||||
|
@ -805,6 +806,7 @@ extern void default_rtl_profile (void);
|
|||
/* In profile.c. */
|
||||
typedef struct gcov_working_set_info gcov_working_set_t;
|
||||
extern gcov_working_set_t *find_working_set (unsigned pct_times_10);
|
||||
extern void add_working_set (gcov_working_set_t *);
|
||||
|
||||
/* Check tha probability is sane. */
|
||||
|
||||
|
|
|
@ -895,6 +895,16 @@ fauto-inc-dec
|
|||
Common Report Var(flag_auto_inc_dec) Init(1)
|
||||
Generate auto-inc/dec instructions
|
||||
|
||||
fauto-profile
|
||||
Common Report Var(flag_auto_profile) Optimization
|
||||
Use sample profile information for call graph node weights. The default
|
||||
profile file is fbdata.afdo in 'pwd'.
|
||||
|
||||
fauto-profile=
|
||||
Common Joined RejectNegative Var(auto_profile_file)
|
||||
Use sample profile information for call graph node weights. The profile
|
||||
file is specified in the argument.
|
||||
|
||||
; -fcheck-bounds causes gcc to generate array bounds checks.
|
||||
; For C, C++ and ObjC: defaults off.
|
||||
; For Java: defaults to on.
|
||||
|
|
|
@ -61,6 +61,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "filenames.h"
|
||||
#include "target.h"
|
||||
#include "params.h"
|
||||
#include "auto-profile.h"
|
||||
|
||||
#include "gcov-io.h"
|
||||
#include "gcov-io.c"
|
||||
|
@ -1214,7 +1215,9 @@ coverage_init (const char *filename)
|
|||
|
||||
bbg_file_stamp = local_tick;
|
||||
|
||||
if (flag_branch_probabilities)
|
||||
if (flag_auto_profile)
|
||||
read_autofdo_file ();
|
||||
else if (flag_branch_probabilities)
|
||||
read_counts_file ();
|
||||
|
||||
/* Name of bbg file. */
|
||||
|
|
|
@ -365,7 +365,8 @@ Objective-C and Objective-C++ Dialects}.
|
|||
@gccoptlist{-faggressive-loop-optimizations -falign-functions[=@var{n}] @gol
|
||||
-falign-jumps[=@var{n}] @gol
|
||||
-falign-labels[=@var{n}] -falign-loops[=@var{n}] @gol
|
||||
-fassociative-math -fauto-inc-dec -fbranch-probabilities @gol
|
||||
-fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
|
||||
-fauto-inc-dec -fbranch-probabilities @gol
|
||||
-fbranch-target-load-optimize -fbranch-target-load-optimize2 @gol
|
||||
-fbtr-bb-exclusive -fcaller-saves @gol
|
||||
-fcheck-data-deps -fcombine-stack-adjustments -fconserve-stack @gol
|
||||
|
@ -9205,6 +9206,41 @@ code.
|
|||
|
||||
If @var{path} is specified, GCC looks at the @var{path} to find
|
||||
the profile feedback data files. See @option{-fprofile-dir}.
|
||||
|
||||
@item -fauto-profile
|
||||
@itemx -fauto-profile=@var{path}
|
||||
@opindex fauto-profile
|
||||
Enable sampling based feedback directed optimizations, and optimizations
|
||||
generally profitable only with profile feedback available.
|
||||
|
||||
The following options are enabled: @code{-fbranch-probabilities}, @code{-fvpt},
|
||||
@code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer}, @code{-ftree-vectorize},
|
||||
@code{-finline-functions}, @code{-fipa-cp}, @code{-fipa-cp-clone},
|
||||
@code{-fpredictive-commoning}, @code{-funswitch-loops},
|
||||
@code{-fgcse-after-reload}, @code{-ftree-loop-distribute-patterns},
|
||||
|
||||
If @var{path} is specified, GCC looks at the @var{path} to find
|
||||
the profile feedback data files.
|
||||
|
||||
In order to collect AutoFDO profile, you need to have:
|
||||
|
||||
1. A linux system with linux perf support
|
||||
2. (optional) An Intel processor with last branch record (LBR) support. This is
|
||||
to guarantee accurate instruction level profile, which is important for
|
||||
AutoFDO performance.
|
||||
|
||||
To collect the profile, first use linux perf to collect raw profile
|
||||
(see @uref{https://perf.wiki.kernel.org/}).
|
||||
|
||||
E.g.
|
||||
@code{perf record -e br_inst_retired:near_taken -b -o perf.data -- your_program}
|
||||
|
||||
Then use create_gcov tool, which takes raw profile and unstripped binary to
|
||||
generate AutoFDO profile that can be used by GCC.
|
||||
(see @uref{https://github.com/google/autofdo}).
|
||||
|
||||
E.g.
|
||||
@code{create_gcov --binary=your_program.unstripped --profile=perf.data --gcov=profile.afdo}
|
||||
@end table
|
||||
|
||||
The following options control compiler behavior regarding floating-point
|
||||
|
|
|
@ -244,6 +244,9 @@ typedef uint64_t gcov_type_unsigned;
|
|||
#define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000)
|
||||
#define GCOV_TAG_SUMMARY_LENGTH(NUM) \
|
||||
(1 + GCOV_COUNTERS_SUMMABLE * (10 + 3 * 2) + (NUM) * 5)
|
||||
#define GCOV_TAG_AFDO_FILE_NAMES ((gcov_unsigned_t)0xaa000000)
|
||||
#define GCOV_TAG_AFDO_FUNCTION ((gcov_unsigned_t)0xac000000)
|
||||
#define GCOV_TAG_AFDO_WORKING_SET ((gcov_unsigned_t)0xaf000000)
|
||||
|
||||
|
||||
/* Counters that are collected. */
|
||||
|
|
|
@ -122,6 +122,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "ipa-inline.h"
|
||||
#include "ipa-utils.h"
|
||||
#include "sreal.h"
|
||||
#include "auto-profile.h"
|
||||
#include "cilk.h"
|
||||
#include "builtins.h"
|
||||
|
||||
|
@ -443,6 +444,14 @@ want_early_inline_function_p (struct cgraph_edge *e)
|
|||
|
||||
if (DECL_DISREGARD_INLINE_LIMITS (callee->decl))
|
||||
;
|
||||
/* For AutoFDO, we need to make sure that before profile annotation, all
|
||||
hot paths' IR look exactly the same as profiled binary. As a result,
|
||||
in einliner, we will disregard size limit and inline those callsites
|
||||
that are:
|
||||
* inlined in the profiled binary, and
|
||||
* the cloned callee has enough samples to be considered "hot". */
|
||||
else if (flag_auto_profile && afdo_callsite_hot_enough_for_early_inline (e))
|
||||
;
|
||||
else if (!DECL_DECLARED_INLINE_P (callee->decl)
|
||||
&& !flag_inline_small_functions)
|
||||
{
|
||||
|
@ -2360,39 +2369,8 @@ early_inline_small_functions (struct cgraph_node *node)
|
|||
return inlined;
|
||||
}
|
||||
|
||||
/* Do inlining of small functions. Doing so early helps profiling and other
|
||||
passes to be somewhat more effective and avoids some code duplication in
|
||||
later real inlining pass for testcases with very many function calls. */
|
||||
|
||||
namespace {
|
||||
|
||||
const pass_data pass_data_early_inline =
|
||||
{
|
||||
GIMPLE_PASS, /* type */
|
||||
"einline", /* name */
|
||||
OPTGROUP_INLINE, /* optinfo_flags */
|
||||
TV_EARLY_INLINING, /* tv_id */
|
||||
PROP_ssa, /* properties_required */
|
||||
0, /* properties_provided */
|
||||
0, /* properties_destroyed */
|
||||
0, /* todo_flags_start */
|
||||
0, /* todo_flags_finish */
|
||||
};
|
||||
|
||||
class pass_early_inline : public gimple_opt_pass
|
||||
{
|
||||
public:
|
||||
pass_early_inline (gcc::context *ctxt)
|
||||
: gimple_opt_pass (pass_data_early_inline, ctxt)
|
||||
{}
|
||||
|
||||
/* opt_pass methods: */
|
||||
virtual unsigned int execute (function *);
|
||||
|
||||
}; // class pass_early_inline
|
||||
|
||||
unsigned int
|
||||
pass_early_inline::execute (function *fun)
|
||||
early_inliner (function *fun)
|
||||
{
|
||||
struct cgraph_node *node = cgraph_node::get (current_function_decl);
|
||||
struct cgraph_edge *edge;
|
||||
|
@ -2493,6 +2471,43 @@ pass_early_inline::execute (function *fun)
|
|||
return todo;
|
||||
}
|
||||
|
||||
/* Do inlining of small functions. Doing so early helps profiling and other
|
||||
passes to be somewhat more effective and avoids some code duplication in
|
||||
later real inlining pass for testcases with very many function calls. */
|
||||
|
||||
namespace {
|
||||
|
||||
const pass_data pass_data_early_inline =
|
||||
{
|
||||
GIMPLE_PASS, /* type */
|
||||
"einline", /* name */
|
||||
OPTGROUP_INLINE, /* optinfo_flags */
|
||||
TV_EARLY_INLINING, /* tv_id */
|
||||
PROP_ssa, /* properties_required */
|
||||
0, /* properties_provided */
|
||||
0, /* properties_destroyed */
|
||||
0, /* todo_flags_start */
|
||||
0, /* todo_flags_finish */
|
||||
};
|
||||
|
||||
class pass_early_inline : public gimple_opt_pass
|
||||
{
|
||||
public:
|
||||
pass_early_inline (gcc::context *ctxt)
|
||||
: gimple_opt_pass (pass_data_early_inline, ctxt)
|
||||
{}
|
||||
|
||||
/* opt_pass methods: */
|
||||
virtual unsigned int execute (function *);
|
||||
|
||||
}; // class pass_early_inline
|
||||
|
||||
unsigned int
|
||||
pass_early_inline::execute (function *fun)
|
||||
{
|
||||
return early_inliner (fun);
|
||||
}
|
||||
|
||||
} // anon namespace
|
||||
|
||||
gimple_opt_pass *
|
||||
|
|
|
@ -238,6 +238,7 @@ void initialize_growth_caches (void);
|
|||
void free_growth_caches (void);
|
||||
void compute_inline_parameters (struct cgraph_node *, bool);
|
||||
bool speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining);
|
||||
unsigned int early_inliner (function *fun);
|
||||
|
||||
/* In ipa-inline-transform.c */
|
||||
bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
|
||||
|
|
100
gcc/opts.c
100
gcc/opts.c
|
@ -1280,6 +1280,50 @@ print_specific_help (unsigned int include_flags,
|
|||
opts->x_help_columns, opts, lang_mask);
|
||||
}
|
||||
|
||||
/* Enable FDO-related flags. */
|
||||
|
||||
static void
|
||||
enable_fdo_optimizations (struct gcc_options *opts,
|
||||
struct gcc_options *opts_set,
|
||||
int value)
|
||||
{
|
||||
if (!opts_set->x_flag_branch_probabilities)
|
||||
opts->x_flag_branch_probabilities = value;
|
||||
if (!opts_set->x_flag_profile_values)
|
||||
opts->x_flag_profile_values = value;
|
||||
if (!opts_set->x_flag_unroll_loops)
|
||||
opts->x_flag_unroll_loops = value;
|
||||
if (!opts_set->x_flag_peel_loops)
|
||||
opts->x_flag_peel_loops = value;
|
||||
if (!opts_set->x_flag_tracer)
|
||||
opts->x_flag_tracer = value;
|
||||
if (!opts_set->x_flag_value_profile_transformations)
|
||||
opts->x_flag_value_profile_transformations = value;
|
||||
if (!opts_set->x_flag_inline_functions)
|
||||
opts->x_flag_inline_functions = value;
|
||||
if (!opts_set->x_flag_ipa_cp)
|
||||
opts->x_flag_ipa_cp = value;
|
||||
if (!opts_set->x_flag_ipa_cp_clone
|
||||
&& value && opts->x_flag_ipa_cp)
|
||||
opts->x_flag_ipa_cp_clone = value;
|
||||
if (!opts_set->x_flag_predictive_commoning)
|
||||
opts->x_flag_predictive_commoning = value;
|
||||
if (!opts_set->x_flag_unswitch_loops)
|
||||
opts->x_flag_unswitch_loops = value;
|
||||
if (!opts_set->x_flag_gcse_after_reload)
|
||||
opts->x_flag_gcse_after_reload = value;
|
||||
if (!opts_set->x_flag_tree_loop_vectorize
|
||||
&& !opts_set->x_flag_tree_vectorize)
|
||||
opts->x_flag_tree_loop_vectorize = value;
|
||||
if (!opts_set->x_flag_tree_slp_vectorize
|
||||
&& !opts_set->x_flag_tree_vectorize)
|
||||
opts->x_flag_tree_slp_vectorize = value;
|
||||
if (!opts_set->x_flag_vect_cost_model)
|
||||
opts->x_flag_vect_cost_model = VECT_COST_MODEL_DYNAMIC;
|
||||
if (!opts_set->x_flag_tree_loop_distribute_patterns)
|
||||
opts->x_flag_tree_loop_distribute_patterns = value;
|
||||
}
|
||||
|
||||
/* Handle target- and language-independent options. Return zero to
|
||||
generate an "unknown option" message. Only options that need
|
||||
extra handling need to be listed here; if you simply want
|
||||
|
@ -1749,50 +1793,30 @@ common_handle_option (struct gcc_options *opts,
|
|||
value = true;
|
||||
/* No break here - do -fprofile-use processing. */
|
||||
case OPT_fprofile_use:
|
||||
if (!opts_set->x_flag_branch_probabilities)
|
||||
opts->x_flag_branch_probabilities = value;
|
||||
if (!opts_set->x_flag_profile_values)
|
||||
opts->x_flag_profile_values = value;
|
||||
if (!opts_set->x_flag_unroll_loops)
|
||||
opts->x_flag_unroll_loops = value;
|
||||
if (!opts_set->x_flag_peel_loops)
|
||||
opts->x_flag_peel_loops = value;
|
||||
if (!opts_set->x_flag_tracer)
|
||||
opts->x_flag_tracer = value;
|
||||
if (!opts_set->x_flag_value_profile_transformations)
|
||||
opts->x_flag_value_profile_transformations = value;
|
||||
if (!opts_set->x_flag_inline_functions)
|
||||
opts->x_flag_inline_functions = value;
|
||||
if (!opts_set->x_flag_ipa_cp)
|
||||
opts->x_flag_ipa_cp = value;
|
||||
if (!opts_set->x_flag_ipa_cp_clone
|
||||
&& value && opts->x_flag_ipa_cp)
|
||||
opts->x_flag_ipa_cp_clone = value;
|
||||
if (!opts_set->x_flag_predictive_commoning)
|
||||
opts->x_flag_predictive_commoning = value;
|
||||
if (!opts_set->x_flag_unswitch_loops)
|
||||
opts->x_flag_unswitch_loops = value;
|
||||
if (!opts_set->x_flag_gcse_after_reload)
|
||||
opts->x_flag_gcse_after_reload = value;
|
||||
if (!opts_set->x_flag_tree_loop_vectorize
|
||||
&& !opts_set->x_flag_tree_vectorize)
|
||||
opts->x_flag_tree_loop_vectorize = value;
|
||||
if (!opts_set->x_flag_tree_slp_vectorize
|
||||
&& !opts_set->x_flag_tree_vectorize)
|
||||
opts->x_flag_tree_slp_vectorize = value;
|
||||
if (!opts_set->x_flag_vect_cost_model)
|
||||
opts->x_flag_vect_cost_model = VECT_COST_MODEL_DYNAMIC;
|
||||
if (!opts_set->x_flag_tree_loop_distribute_patterns)
|
||||
opts->x_flag_tree_loop_distribute_patterns = value;
|
||||
enable_fdo_optimizations (opts, opts_set, value);
|
||||
if (!opts_set->x_flag_profile_reorder_functions)
|
||||
opts->x_flag_profile_reorder_functions = value;
|
||||
/* Indirect call profiling should do all useful transformations
|
||||
speculative devirtualization does. */
|
||||
opts->x_flag_profile_reorder_functions = value;
|
||||
/* Indirect call profiling should do all useful transformations
|
||||
speculative devirtualization does. */
|
||||
if (!opts_set->x_flag_devirtualize_speculatively
|
||||
&& opts->x_flag_value_profile_transformations)
|
||||
opts->x_flag_devirtualize_speculatively = false;
|
||||
break;
|
||||
|
||||
case OPT_fauto_profile_:
|
||||
opts->x_auto_profile_file = xstrdup (arg);
|
||||
opts->x_flag_auto_profile = true;
|
||||
value = true;
|
||||
/* No break here - do -fauto-profile processing. */
|
||||
case OPT_fauto_profile:
|
||||
enable_fdo_optimizations (opts, opts_set, value);
|
||||
if (!opts_set->x_flag_profile_correction)
|
||||
opts->x_flag_profile_correction = value;
|
||||
maybe_set_param_value (
|
||||
PARAM_EARLY_INLINER_MAX_ITERATIONS, 10,
|
||||
opts->x_param_values, opts_set->x_param_values);
|
||||
break;
|
||||
|
||||
case OPT_fprofile_generate_:
|
||||
opts->x_profile_data_prefix = xstrdup (arg);
|
||||
value = true;
|
||||
|
|
|
@ -90,6 +90,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
NEXT_PASS (pass_rebuild_cgraph_edges);
|
||||
NEXT_PASS (pass_inline_parameters);
|
||||
POP_INSERT_PASSES ()
|
||||
NEXT_PASS (pass_ipa_auto_profile);
|
||||
NEXT_PASS (pass_ipa_free_inline_summary);
|
||||
NEXT_PASS (pass_ipa_tree_profile);
|
||||
PUSH_INSERT_PASSES_WITHIN (pass_ipa_tree_profile)
|
||||
|
|
|
@ -167,7 +167,7 @@ set_hot_bb_threshold (gcov_type min)
|
|||
|
||||
/* Return TRUE if frequency FREQ is considered to be hot. */
|
||||
|
||||
static inline bool
|
||||
bool
|
||||
maybe_hot_count_p (struct function *fun, gcov_type count)
|
||||
{
|
||||
if (fun && profile_status_for_fn (fun) != PROFILE_READ)
|
||||
|
@ -2859,7 +2859,7 @@ counts_to_freqs (void)
|
|||
/* Don't overwrite the estimated frequencies when the profile for
|
||||
the function is missing. We may drop this function PROFILE_GUESSED
|
||||
later in drop_profile (). */
|
||||
if (!ENTRY_BLOCK_PTR_FOR_FN (cfun)->count)
|
||||
if (!flag_auto_profile && !ENTRY_BLOCK_PTR_FOR_FN (cfun)->count)
|
||||
return 0;
|
||||
|
||||
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb)
|
||||
|
@ -3230,7 +3230,8 @@ rebuild_frequencies (void)
|
|||
count_max = MAX (bb->count, count_max);
|
||||
|
||||
if (profile_status_for_fn (cfun) == PROFILE_GUESSED
|
||||
|| (profile_status_for_fn (cfun) == PROFILE_READ && count_max < REG_BR_PROB_BASE/10))
|
||||
|| (!flag_auto_profile && profile_status_for_fn (cfun) == PROFILE_READ
|
||||
&& count_max < REG_BR_PROB_BASE/10))
|
||||
{
|
||||
loop_optimizer_init (0);
|
||||
add_noreturn_fake_exit_edges ();
|
||||
|
|
|
@ -112,6 +112,14 @@ static int total_num_times_called;
|
|||
static int total_hist_br_prob[20];
|
||||
static int total_num_branches;
|
||||
|
||||
/* Helper function to update gcov_working_sets. */
|
||||
|
||||
void add_working_set (gcov_working_set_t *set) {
|
||||
int i = 0;
|
||||
for (; i < NUM_GCOV_WORKING_SETS; i++)
|
||||
gcov_working_sets[i] = set[i];
|
||||
}
|
||||
|
||||
/* Forward declarations. */
|
||||
static void find_spanning_tree (struct edge_list *);
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ DEFTIMEVAR (TV_WHOPR_PARTITIONING , "whopr partitioning")
|
|||
DEFTIMEVAR (TV_WHOPR_LTRANS , "whopr ltrans")
|
||||
DEFTIMEVAR (TV_IPA_REFERENCE , "ipa reference")
|
||||
DEFTIMEVAR (TV_IPA_PROFILE , "ipa profile")
|
||||
DEFTIMEVAR (TV_IPA_AUTOFDO , "auto profile")
|
||||
DEFTIMEVAR (TV_IPA_PURE_CONST , "ipa pure const")
|
||||
DEFTIMEVAR (TV_IPA_ICF , "ipa icf")
|
||||
DEFTIMEVAR (TV_IPA_PTA , "ipa points-to")
|
||||
|
|
|
@ -83,6 +83,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "diagnostic-color.h"
|
||||
#include "context.h"
|
||||
#include "pass_manager.h"
|
||||
#include "auto-profile.h"
|
||||
#include "dwarf2out.h"
|
||||
#include "ipa-reference.h"
|
||||
#include "ipa-prop.h"
|
||||
|
@ -671,6 +672,10 @@ compile_file (void)
|
|||
targetm.asm_out.output_ident (ident_str);
|
||||
}
|
||||
|
||||
/* Auto profile finalization. */
|
||||
if (flag_auto_profile)
|
||||
end_auto_profile ();
|
||||
|
||||
/* Invoke registered plugin callbacks. */
|
||||
invoke_plugin_callbacks (PLUGIN_FINISH_UNIT, NULL);
|
||||
|
||||
|
|
|
@ -449,6 +449,7 @@ extern simple_ipa_opt_pass *make_pass_ipa_lower_emutls (gcc::context *ctxt);
|
|||
extern simple_ipa_opt_pass
|
||||
*make_pass_ipa_function_and_variable_visibility (gcc::context *ctxt);
|
||||
extern simple_ipa_opt_pass *make_pass_ipa_tree_profile (gcc::context *ctxt);
|
||||
extern simple_ipa_opt_pass *make_pass_ipa_auto_profile (gcc::context *ctxt);
|
||||
|
||||
extern simple_ipa_opt_pass *make_pass_early_local_passes (gcc::context *ctxt);
|
||||
|
||||
|
|
|
@ -719,8 +719,10 @@ public:
|
|||
bool
|
||||
pass_ipa_tree_profile::gate (function *)
|
||||
{
|
||||
/* When profile instrumentation, use or test coverage shall be performed. */
|
||||
return (!in_lto_p
|
||||
/* When profile instrumentation, use or test coverage shall be performed.
|
||||
But for AutoFDO, this there is no instrumentation, thus this pass is
|
||||
diabled. */
|
||||
return (!in_lto_p && !flag_auto_profile
|
||||
&& (flag_branch_probabilities || flag_test_coverage
|
||||
|| profile_arc_flag));
|
||||
}
|
||||
|
|
|
@ -605,7 +605,7 @@ remove_unused_scope_block_p (tree scope)
|
|||
;
|
||||
/* When not generating debug info we can eliminate info on unused
|
||||
variables. */
|
||||
else if (debug_info_level == DINFO_LEVEL_NONE)
|
||||
else if (!flag_auto_profile && debug_info_level == DINFO_LEVEL_NONE)
|
||||
{
|
||||
/* Even for -g0 don't prune outer scopes from artificial
|
||||
functions, otherwise diagnostics using tree_nonartificial_location
|
||||
|
|
|
@ -139,7 +139,7 @@ static bool gimple_ic_transform (gimple_stmt_iterator *);
|
|||
|
||||
/* Allocate histogram value. */
|
||||
|
||||
static histogram_value
|
||||
histogram_value
|
||||
gimple_alloc_histogram_value (struct function *fun ATTRIBUTE_UNUSED,
|
||||
enum hist_type type, gimple stmt, tree value)
|
||||
{
|
||||
|
@ -1342,7 +1342,7 @@ find_func_by_profile_id (int profile_id)
|
|||
may ICE. Here we only do very minimal sanity check just to make compiler happy.
|
||||
Returns true if TARGET is considered ok for call CALL_STMT. */
|
||||
|
||||
static bool
|
||||
bool
|
||||
check_ic_target (gimple call_stmt, struct cgraph_node *target)
|
||||
{
|
||||
location_t locus;
|
||||
|
|
|
@ -77,6 +77,8 @@ typedef vec<histogram_value> histogram_values;
|
|||
extern void gimple_find_values_to_profile (histogram_values *);
|
||||
extern bool gimple_value_profile_transformations (void);
|
||||
|
||||
histogram_value gimple_alloc_histogram_value (struct function *, enum hist_type,
|
||||
gimple stmt, tree);
|
||||
histogram_value gimple_histogram_value (struct function *, gimple);
|
||||
histogram_value gimple_histogram_value_of_type (struct function *, gimple,
|
||||
enum hist_type);
|
||||
|
@ -91,6 +93,7 @@ void verify_histograms (void);
|
|||
void free_histograms (void);
|
||||
void stringop_block_profile (gimple, unsigned int *, HOST_WIDE_INT *);
|
||||
gimple gimple_ic (gimple, struct cgraph_node *, int, gcov_type, gcov_type);
|
||||
bool check_ic_target (gimple, struct cgraph_node *);
|
||||
|
||||
|
||||
/* In tree-profile.c. */
|
||||
|
|
Loading…
Add table
Reference in a new issue