aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2021-11-28 19:25:33 +0100
committerJan Hubicka <jh@suse.cz>2021-11-28 19:25:33 +0100
commitd1471457fcda26cd24e0053b82f8eed35ddb8727 (patch)
treeccb130300fe101af002265cb1efebb51938b17a1 /gcc/tree-cfg.c
parent7393fa8b1d21eeeb37e59ff8efaebf178fd891e5 (diff)
downloadgcc-d1471457fcda26cd24e0053b82f8eed35ddb8727.zip
gcc-d1471457fcda26cd24e0053b82f8eed35ddb8727.tar.gz
gcc-d1471457fcda26cd24e0053b82f8eed35ddb8727.tar.bz2
Improve -fprofile-report
Profile-report was never properly updated after switch to new profile representation. This patch fixes the way profile mismatches are calculated: we used to collect separately count and freq mismatches, while now we have only counts & probabilities. So we verify - in count: that total count of incomming edges is close to acutal count of the BB - out prob: that total sum of outgoing edge edge probabilities is close to 1 (except for BB containing noreturn calls or EH). Moreover I added dumping of absolute data which is useful to plot them: with Martin Liska we plan to setup regular testing so we keep optimizers profie updates bit under control. Finally I added both static and dynamic stats about mismatches - static one is simply number of inconsistencies in the cfg while dynamic is scaled by the profile - I think in order to keep eye on optimizers the first number is quite relevant. WHile when tracking why code quality regressed the second number matters more. 2021-11-28 Jan Hubicka <hubicka@ucw.cz> * cfghooks.c: Include sreal.h, profile.h. (profile_record_check_consistency): Fix checking of count counsistency; record also dynamic mismatches. * cfgrtl.c (rtl_account_profile_record): Similarly. * tree-cfg.c (gimple_account_profile_record): Likewise. * cfghooks.h (struct profile_record): Remove num_mismatched_freq_in, num_mismatched_freq_out, turn time to double, add dyn_mismatched_prob_out, dyn_mismatched_count_in, num_mismatched_prob_out; remove num_mismatched_count_out. * passes.c (account_profile_1): New function. (account_profile_in_list): New function. (pass_manager::dump_profile_report): Rewrite. (execute_one_ipa_transform_pass): Check profile consistency after running all passes. (execute_all_ipa_transforms): Remove cfun test; record all transform methods. (execute_one_pass): Fix collecting of profile stats.
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 8ed8c69..ebbd894 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3. If not see
#include "opts.h"
#include "asan.h"
#include "profile.h"
+#include "sreal.h"
/* This file contains functions for building the Control Flow Graph (CFG)
for a function tree. */
@@ -9084,18 +9085,32 @@ gimple_account_profile_record (basic_block bb,
struct profile_record *record)
{
gimple_stmt_iterator i;
- for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
+ for (i = gsi_start_nondebug_after_labels_bb (bb); !gsi_end_p (i);
+ gsi_next_nondebug (&i))
{
record->size
+= estimate_num_insns (gsi_stmt (i), &eni_size_weights);
- if (bb->count.initialized_p ())
+ if (profile_info)
+ {
+ if (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa ().initialized_p ()
+ && ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa ().nonzero_p ()
+ && bb->count.ipa ().initialized_p ())
+ record->time
+ += estimate_num_insns (gsi_stmt (i),
+ &eni_time_weights)
+ * bb->count.ipa ().to_gcov_type ();
+ }
+ else if (bb->count.initialized_p ()
+ && ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.initialized_p ())
record->time
- += estimate_num_insns (gsi_stmt (i),
- &eni_time_weights) * bb->count.to_gcov_type ();
- else if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
- record->time
- += estimate_num_insns (gsi_stmt (i),
- &eni_time_weights) * bb->count.to_frequency (cfun);
+ += estimate_num_insns
+ (gsi_stmt (i),
+ &eni_time_weights)
+ * bb->count.to_sreal_scale
+ (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count).to_double ();
+ else
+ record->time
+ += estimate_num_insns (gsi_stmt (i), &eni_time_weights);
}
}