aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.cc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2023-08-24 15:10:46 +0200
committerJan Hubicka <jh@suse.cz>2023-08-24 15:10:46 +0200
commit0c78240fd7d519fc27ca822f66a92f85edf43f70 (patch)
tree273eeb0cf60590b12f8d1d7efbcf7e1d9c4676f3 /gcc/tree-cfg.cc
parent7564fe98657ad5ede34bd08f5279778fa8698865 (diff)
downloadgcc-0c78240fd7d519fc27ca822f66a92f85edf43f70.zip
gcc-0c78240fd7d519fc27ca822f66a92f85edf43f70.tar.gz
gcc-0c78240fd7d519fc27ca822f66a92f85edf43f70.tar.bz2
Check that passes do not forget to define profile
This patch extends verifier to check that all probabilities and counts are initialized if profile is supposed to be present. This is a bit complicated by the posibility that we inline !flag_guess_branch_probability function into function with profile defined and in this case we need to stop verification. For this reason I added flag to cfg structure tracking this. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: * cfg.h (struct control_flow_graph): New field full_profile. * auto-profile.cc (afdo_annotate_cfg): Set full_profile to true. * cfg.cc (init_flow): Set full_profile to false. * graphite.cc (graphite_transform_loops): Set full_profile to false. * lto-streamer-in.cc (input_cfg): Initialize full_profile flag. * predict.cc (pass_profile::execute): Set full_profile to true. * symtab-thunks.cc (expand_thunk): Set full_profile to true. * tree-cfg.cc (gimple_verify_flow_info): Verify that profile is full if full_profile is set. * tree-inline.cc (initialize_cfun): Initialize full_profile. (expand_call_inline): Combine full_profile.
Diffstat (limited to 'gcc/tree-cfg.cc')
-rw-r--r--gcc/tree-cfg.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 272d5ce..ffab751 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -5684,6 +5684,26 @@ gimple_verify_flow_info (void)
error ("fallthru to exit from bb %d", e->src->index);
err = true;
}
+ if (cfun->cfg->full_profile
+ && !ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.initialized_p ())
+ {
+ error ("entry block count not initialized");
+ err = true;
+ }
+ if (cfun->cfg->full_profile
+ && !EXIT_BLOCK_PTR_FOR_FN (cfun)->count.initialized_p ())
+ {
+ error ("exit block count not initialized");
+ err = true;
+ }
+ if (cfun->cfg->full_profile
+ && !single_succ_edge
+ (ENTRY_BLOCK_PTR_FOR_FN (cfun))->probability.initialized_p ())
+ {
+ error ("probability of edge from entry block not initialized");
+ err = true;
+ }
+
FOR_EACH_BB_FN (bb, cfun)
{
@@ -5691,6 +5711,22 @@ gimple_verify_flow_info (void)
stmt = NULL;
+ if (cfun->cfg->full_profile)
+ {
+ if (!bb->count.initialized_p ())
+ {
+ error ("count of bb %d not initialized", bb->index);
+ err = true;
+ }
+ FOR_EACH_EDGE (e, ei, bb->succs)
+ if (!e->probability.initialized_p ())
+ {
+ error ("probability of edge %d->%d not initialized",
+ bb->index, e->dest->index);
+ err = true;
+ }
+ }
+
/* Skip labels on the start of basic block. */
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{