Enhance dump_probability function.
authorMartin Liska <mliska@suse.cz>
Tue, 13 Jun 2017 08:59:28 +0000 (10:59 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 13 Jun 2017 08:59:28 +0000 (08:59 +0000)
2017-06-13  Martin Liska  <mliska@suse.cz>

* gimple-pretty-print.c (dump_probability): Add new argument.
(dump_edge_probability): Dump both probability and count.
(dump_gimple_label): Likewise.
(dump_gimple_bb_header): Likewise.
2017-06-13  Martin Liska  <mliska@suse.cz>

* gcc.dg/tree-ssa/builtin-sprintf-2.c: Adjust scanned pattern.
* gcc.dg/tree-ssa/dump-2.c: Likewise.
* gcc.dg/tree-ssa/vrp101.c: Likewise.

From-SVN: r249147

gcc/ChangeLog
gcc/gimple-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
gcc/testsuite/gcc.dg/tree-ssa/dump-2.c
gcc/testsuite/gcc.dg/tree-ssa/vrp101.c

index b5159ee4cf646c2f281be7491cfa9cd89ce3c877..344e5fa43b34a97fc6d160f8fd64e9bb18bf8486 100644 (file)
@@ -1,3 +1,10 @@
+2017-06-13  Martin Liska  <mliska@suse.cz>
+
+       * gimple-pretty-print.c (dump_probability): Add new argument.
+       (dump_edge_probability): Dump both probability and count.
+       (dump_gimple_label): Likewise.
+       (dump_gimple_bb_header): Likewise.
+
 2017-06-13  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/81072
index 5ff63a167a1b5ba6e900ec792bf79a7c7a1ebac3..447921be036f3190a36e6de26540b42bdf2b9d48 100644 (file)
@@ -80,17 +80,22 @@ debug_gimple_stmt (gimple *gs)
    by xstrdup_for_dump.  */
 
 static const char *
-dump_probability (int value)
+dump_probability (int frequency, profile_count &count)
 {
   float minimum = 0.01f;
 
-  gcc_assert (0 <= value && value <= REG_BR_PROB_BASE);
-  float fvalue = value * 100.0f / REG_BR_PROB_BASE;
-  if (fvalue < minimum && value > 0)
+  gcc_assert (0 <= frequency && frequency <= REG_BR_PROB_BASE);
+  float fvalue = frequency * 100.0f / REG_BR_PROB_BASE;
+  if (fvalue < minimum && frequency > 0)
     return "[0.01%]";
 
   char *buf;
-  asprintf (&buf, "[%.2f%%]", fvalue);
+  if (count.initialized_p ())
+    asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
+             count.to_gcov_type ());
+  else
+    asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
+
   const char *ret = xstrdup_for_dump (buf);
   free (buf);
 
@@ -102,7 +107,7 @@ dump_probability (int value)
 static void
 dump_edge_probability (pretty_printer *buffer, edge e)
 {
-  pp_scalar (buffer, " %s", dump_probability (e->probability));
+  pp_scalar (buffer, " %s", dump_probability (e->probability, e->count));
 }
 
 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
@@ -1085,7 +1090,7 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
       dump_generic_node (buffer, label, spc, flags, false);
       basic_block bb = gimple_bb (gs);
       if (bb && !(flags & TDF_GIMPLE))
-       pp_scalar (buffer, " %s", dump_probability (bb->frequency));
+       pp_scalar (buffer, " %s", dump_probability (bb->frequency, bb->count));
       pp_colon (buffer);
     }
   if (flags & TDF_GIMPLE)
@@ -2665,7 +2670,8 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
            fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
          else
            fprintf (outf, "%*s<bb %d> %s:\n",
-                    indent, "", bb->index, dump_probability (bb->frequency));
+                    indent, "", bb->index, dump_probability (bb->frequency,
+                                                             bb->count));
        }
     }
 }
index 5e9d5ffaef220559896a206d15b0f9fae04e2865..37ea126831294f0d5b797550828775b5300bc01e 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-13  Martin Liska  <mliska@suse.cz>
+
+       * gcc.dg/tree-ssa/builtin-sprintf-2.c: Adjust scanned pattern.
+       * gcc.dg/tree-ssa/dump-2.c: Likewise.
+       * gcc.dg/tree-ssa/vrp101.c: Likewise.
+
 2017-06-13  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/81065
index 8a13f33d2a1e9ef25b2472835f2bb320a0d051c0..e15d88b7341df201e8b80f8a6c0251a5d021c035 100644 (file)
@@ -290,7 +290,7 @@ RNG (0,  6,   8, "%s%ls", "1", L"2");
 
 /*  Only conditional calls to must_not_eliminate must be made (with
     any probability):
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
     No unconditional calls to abort should be made:
     { dg-final { scan-tree-dump-not ";\n *must_not_eliminate" "optimized" } } */
index 8a63af4e0efe656295dd553005edcdce79321e1d..6ae2ef5bf3950b7b233314b7fa7dc33adb25396c 100644 (file)
@@ -6,4 +6,4 @@ int f(void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.00%\\\]:" "optimized" } } */
+/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.00%\\\] \\\[count: INV\\\]:" "optimized" } } */
index bf4109f7156c47d9c78e83e93034e910fc45dba2..e7cad2897632b6a9cc2446f01b985dd09ee83360 100644 (file)
@@ -10,4 +10,4 @@ int main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\]:\[\n\r \]*return 0;" "optimized" } } */
+/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */