diff options
author | Richard Henderson <rth@redhat.com> | 2012-07-26 14:31:40 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2012-07-26 14:31:40 -0700 |
commit | e45abe1f20e35a461c2378f4caf8b1455c98385d (patch) | |
tree | 20c51469f397cdea4c543dc55b62a9a1b3ce14d1 /gcc/predict.c | |
parent | 27ec0502c807dd79b1e6782806ac2d95bd084a6a (diff) | |
download | gcc-e45abe1f20e35a461c2378f4caf8b1455c98385d.zip gcc-e45abe1f20e35a461c2378f4caf8b1455c98385d.tar.gz gcc-e45abe1f20e35a461c2378f4caf8b1455c98385d.tar.bz2 |
Hot/cold attributes for labels.
gcc/
* doc/extend.texi (attribute): Document hot/cold for labels.
* predict.c (tree_estimate_probability_bb): Handle hot/cold
attributes on user labels.
* predict.def (PRED_HOT_LABEL, PRED_COLD_LABEL): New.
gcc/c-family/
* c-common.c (handle_hot_attribute): Allow labels.
(handle_cold_attribute): Likewise.
gcc/testsuite/
* gcc.dg/attr-hotcold-1.c: New.
* gcc.dg/tree-ssa/attr-hotcold-2.c: New.
From-SVN: r189898
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index b690bdc..b8acdba 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -2059,6 +2059,29 @@ tree_estimate_probability_bb (basic_block bb) FOR_EACH_EDGE (e, ei, bb->succs) { + /* Predict edges to user labels with attributes. */ + if (e->dest != EXIT_BLOCK_PTR) + { + gimple_stmt_iterator gi; + for (gi = gsi_start_bb (e->dest); !gsi_end_p (gi); gsi_next (&gi)) + { + gimple stmt = gsi_stmt (gi); + tree decl; + + if (gimple_code (stmt) != GIMPLE_LABEL) + break; + decl = gimple_label_label (stmt); + if (DECL_ARTIFICIAL (decl)) + continue; + + /* Finally, we have a user-defined label. */ + if (lookup_attribute ("cold", DECL_ATTRIBUTES (decl))) + predict_edge_def (e, PRED_COLD_LABEL, NOT_TAKEN); + else if (lookup_attribute ("hot", DECL_ATTRIBUTES (decl))) + predict_edge_def (e, PRED_HOT_LABEL, TAKEN); + } + } + /* Predict early returns to be probable, as we've already taken care for error returns and other cases are often used for fast paths through function. |