This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Better tolerance of incoming profile insanities in jump threading


The below patch fixes the overflow detection when recomputing
probabilities after jump threading, in case of incoming profile
insanities. It detects more cases where the computation will overflow
not only the max probability but the max int and possibly wrap around.

LTO profilebootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for trunk?

Thanks,
Teresa


2014-10-14  Teresa Johnson  <tejohnson@google.com>

        PR bootstrap/63432
        * tree-ssa-threadupdate.c (recompute_probabilities): Better
        overflow checking.

Index: tree-ssa-threadupdate.c
===================================================================
--- tree-ssa-threadupdate.c     (revision 216150)
+++ tree-ssa-threadupdate.c     (working copy)
@@ -871,21 +871,23 @@ recompute_probabilities (basic_block bb)
   edge_iterator ei;
   FOR_EACH_EDGE (esucc, ei, bb->succs)
     {
-      if (bb->count)
+      if (!bb->count)
+        continue;
+
+      /* Prevent overflow computation due to insane profiles.  */
+      if (esucc->count < bb->count)
         esucc->probability = GCOV_COMPUTE_SCALE (esucc->count,
                                                  bb->count);
-      if (esucc->probability > REG_BR_PROB_BASE)
-        {
-         /* Can happen with missing/guessed probabilities, since we
-            may determine that more is flowing along duplicated
-            path than joiner succ probabilities allowed.
-            Counts and freqs will be insane after jump threading,
-            at least make sure probability is sane or we will
-            get a flow verification error.
-            Not much we can do to make counts/freqs sane without
-            redoing the profile estimation.  */
-         esucc->probability = REG_BR_PROB_BASE;
-       }
+      else
+        /* Can happen with missing/guessed probabilities, since we
+           may determine that more is flowing along duplicated
+           path than joiner succ probabilities allowed.
+           Counts and freqs will be insane after jump threading,
+           at least make sure probability is sane or we will
+           get a flow verification error.
+           Not much we can do to make counts/freqs sane without
+           redoing the profile estimation.  */
+        esucc->probability = REG_BR_PROB_BASE;
     }
 }

-- 
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]