From d276406ac1e7fc7f9c380325c994cf477b3d6fb8 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 9 May 2019 15:03:28 +0200 Subject: Support profile (BB counts and edge probabilities) in GIMPLE FE. 2019-05-09 Martin Liska * 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 * 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 * gcc.dg/gimplefe-37.c: New test. * gcc.dg/gimplefe-33.c: Likewise. From-SVN: r271034 --- gcc/profile-count.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'gcc/profile-count.h') diff --git a/gcc/profile-count.h b/gcc/profile-count.h index d6de61f..2669f0d 100644 --- a/gcc/profile-count.h +++ b/gcc/profile-count.h @@ -60,6 +60,8 @@ enum profile_quality { }; extern const char *profile_quality_as_string (enum profile_quality); +extern bool parse_profile_quality (const char *value, + profile_quality *quality); /* The base value for branch probability notes and edge probabilities. */ #define REG_BR_PROB_BASE 10000 @@ -149,6 +151,13 @@ class GTY((user)) profile_probability friend class profile_count; public: + profile_probability (): m_val (uninitialized_probability), + m_quality (profile_guessed) + {} + + profile_probability (uint32_t val, profile_quality quality): + m_val (val), m_quality (quality) + {} /* Named probabilities. */ static profile_probability never () @@ -558,6 +567,12 @@ public: return initialized_p () && other.initialized_p () && m_val >= other.m_val; } + /* Get the value of the count. */ + uint32_t value () const { return m_val; } + + /* Get the quality of the count. */ + enum profile_quality quality () const { return m_quality; } + /* Output THIS to F. */ void dump (FILE *f) const; @@ -675,7 +690,6 @@ private: return ipa_p () == other.ipa_p (); } public: - /* Used for counters which are expected to be never executed. */ static profile_count zero () { @@ -737,6 +751,9 @@ public: return m_quality == profile_precise; } + /* Get the value of the count. */ + uint32_t value () const { return m_val; } + /* Get the quality of the count. */ enum profile_quality quality () const { return m_quality; } @@ -1136,7 +1153,8 @@ public: /* The profiling runtime uses gcov_type, which is usually 64bit integer. Conversions back and forth are used to read the coverage and get it into internal representation. */ - static profile_count from_gcov_type (gcov_type v); + static profile_count from_gcov_type (gcov_type v, + profile_quality quality = profile_precise); /* LTO streaming support. */ static profile_count stream_in (struct lto_input_block *); -- cgit v1.1