aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-05-09 15:03:28 +0200
committerMartin Liska <marxin@gcc.gnu.org>2019-05-09 13:03:28 +0000
commitd276406ac1e7fc7f9c380325c994cf477b3d6fb8 (patch)
treeaaacbcded0429a0522a06ff2c662c5f3910bcaf4 /gcc/tree-cfg.c
parent555dbc42b2dfed0c9e70e9e53fcd569f82aeae02 (diff)
downloadgcc-d276406ac1e7fc7f9c380325c994cf477b3d6fb8.zip
gcc-d276406ac1e7fc7f9c380325c994cf477b3d6fb8.tar.gz
gcc-d276406ac1e7fc7f9c380325c994cf477b3d6fb8.tar.bz2
Support profile (BB counts and edge probabilities) in GIMPLE FE.
2019-05-09 Martin Liska <mliska@suse.cz> * tree-cfg.c (dump_function_to_file): Dump entry BB count. * gimple-pretty-print.c (dump_gimple_bb_header): Dump BB count. (pp_cfg_jump): Dump edge probability. * profile-count.c (profile_quality_as_string): Simplify with a static array. (parse_profile_quality): New function. (profile_count::dump): Simplify with a static array. (profile_count::from_gcov_type): Add new argument. * profile-count.h (parse_profile_quality): Likewise. * predict.h (set_hot_bb_threshold): New. * params.def (PARAM_GIMPLE_FE_COMPUTED_HOT_BB_THRESHOLD): New param. * predict.c (get_hot_bb_threshold): Set from the new param. (set_hot_bb_threshold): New. 2019-05-09 Martin Liska <mliska@suse.cz> * gimple-parser.c (struct gimple_parser): Add probability. for gimple_parser_edge. (gimple_parser::push_edge): Add new argument probability. (c_parser_gimple_parse_bb_spec): Parse also probability if present. (c_parser_parse_gimple_body): Set edge probability. (c_parser_gimple_compound_statement): Consume token before calling c_parser_gimple_goto_stmt. Parse BB counts. (c_parser_gimple_statement): Pass new argument. (c_parser_gimple_goto_stmt): Likewise. (c_parser_gimple_if_stmt): Likewise. (c_parser_gimple_or_rtl_pass_list): Parse hot_bb_threshold. * c-parser.c (c_parser_declaration_or_fndef): Pass hot_bb_threshold argument. * c-tree.h (struct c_declspecs): Add hot_bb_threshold field. (c_parser_gimple_parse_bb_spec_edge_probability): New. 2019-05-09 Martin Liska <mliska@suse.cz> * gcc.dg/gimplefe-37.c: New test. * gcc.dg/gimplefe-33.c: Likewise. From-SVN: r271034
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 5874081..966ce5a 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see
#include "selftest.h"
#include "opts.h"
#include "asan.h"
+#include "profile.h"
/* This file contains functions for building the Control Flow Graph (CFG)
for a function tree. */
@@ -7872,13 +7873,32 @@ dump_function_to_file (tree fndecl, FILE *file, dump_flags_t flags)
current_function_decl = fndecl;
if (flags & TDF_GIMPLE)
{
+ static bool hotness_bb_param_printed = false;
+ if (profile_info != NULL
+ && !hotness_bb_param_printed)
+ {
+ hotness_bb_param_printed = true;
+ fprintf (file,
+ "/* --param=gimple-fe-computed-hot-bb-threshold=%" PRId64
+ " */\n", get_hot_bb_threshold ());
+ }
+
print_generic_expr (file, TREE_TYPE (TREE_TYPE (fndecl)),
dump_flags | TDF_SLIM);
- fprintf (file, " __GIMPLE (%s)\n%s (",
+ fprintf (file, " __GIMPLE (%s",
(fun->curr_properties & PROP_ssa) ? "ssa"
: (fun->curr_properties & PROP_cfg) ? "cfg"
- : "",
- function_name (fun));
+ : "");
+
+ if (cfun->cfg)
+ {
+ basic_block bb = ENTRY_BLOCK_PTR_FOR_FN (cfun);
+ if (bb->count.initialized_p ())
+ fprintf (file, ",%s(%d)",
+ profile_quality_as_string (bb->count.quality ()),
+ bb->count.value ());
+ fprintf (file, ")\n%s (", function_name (fun));
+ }
}
else
fprintf (file, "%s %s(", function_name (fun), tmclone ? "[tm-clone] " : "");