This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[GOOGLE] Fix a bug when profile propagation handles infinite loop.
- From: Dehao Chen <dehao at google dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: David Li <davidxl at google dot com>
- Date: Fri, 25 Oct 2013 16:10:31 -0700
- Subject: [GOOGLE] Fix a bug when profile propagation handles infinite loop.
- Authentication-results: sourceware.org; auth=none
If the propagation finds an infinite look, if the in-edge count is
non-zero, then it will cause compiler go into infinite loop when
building with AutoFDO.
Bootstrapped and regression test on-going.
OK for google-4_8 branch?
Thanks,
Dehao
Index: gcc/auto-profile.c
===================================================================
--- gcc/auto-profile.c (revision 204027)
+++ gcc/auto-profile.c (working copy)
@@ -1287,6 +1287,7 @@ afdo_propagate (void)
{
basic_block bb;
bool changed = true;
+ int i = 0;
FOR_ALL_BB (bb)
{
@@ -1295,7 +1296,7 @@ afdo_propagate (void)
bb->flags |= BB_ANNOTATED;
}
- while (changed)
+ while (changed && i++ < PARAM_VALUE (PARAM_AUTOFDO_MAX_PROPAGATE_ITERATIONS))
{
changed = false;
Index: gcc/params.def
===================================================================
--- gcc/params.def (revision 204027)
+++ gcc/params.def (working copy)
@@ -460,6 +460,14 @@ DEFPARAM(PARAM_MAX_PREDICTED_ITERATIONS,
"The maximum number of loop iterations we predict statically",
100, 0, 0)
+/* This parameter controls the maximum iterations that AutoFDO profile
+ prpagation algorithm will run for a specific CFG. */
+
+DEFPARAM(PARAM_AUTOFDO_MAX_PROPAGATE_ITERATIONS,
+ "max-autofdo-max-propagate-iterations",
+ "The maximum number of AutoFDO profile propagation iterations",
+ 1000, 0, 0)
+
/* This parameter controls the probability of builtin_expect. The default
value is 90%. This empirical value is obtained through the weighted
probability of FDO counters (with the FDO count value as the weight)