On 11/30/2016 11:46 PM, Martin Sebor wrote:
On 11/24/2016 05:59 AM, Martin Liška wrote:
On 11/24/2016 09:29 AM, Richard Biener wrote:
Please guard with ! TDF_GIMPLE, otherwise the output will not be parseable
with the GIMPLE FE.
RIchard.
Done and verified that and it provides equal dumps for -fdump*-gimple.
Installed as r242837.
Hi Martin,
I'm trying to understand how to interpret the probabilities (to
make sure one of my tests, builtin-sprintf-2.c, is testing what
it's supposed to be testing).
With this example:
char d2[2];
void f (void)
{
if (2 != __builtin_sprintf (d2, "%i", 12))
__builtin_abort ();
}
the probability of the branch to abort is 0%:
f1 ()
{
int _1;
<bb 2> [100.0%]:
_1 = __builtin_sprintf (&d, "%i", 12);
if (_1 != 2)
goto <bb 3>; [0.0%]
else
goto <bb 4>; [100.0%]
<bb 3> [0.0%]:
__builtin_abort ();
<bb 4> [100.0%]:
return;
}
Hello Martin.
Looks I did a small error. I use only only one digit after decimal point, which
is unable to
display noreturn predictor (defined as PROB_VERY_UNLIKELY):
#define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1) // this is 4
I would suggest to use following patch to display at least 2 digits, that would
distinguish
between real zero and PROB_VERY_UNLIKELY:
x.c.046t.profile_estimate:
f ()
{
int _1;
<bb 2> [100.00%]:
_1 = __builtin_sprintf (&d2, "%i", 12);
if (_1 != 2)
goto <bb 3>; [0.04%]
else
goto <bb 4>; [99.96%]
<bb 3> [0.04%]:
__builtin_abort ();
<bb 4> [99.96%]:
return;
}
Yet the call to abort is in the assembly so I would expect its
probability to be more than zero. So my question is: it it safe
to be testing for calls to abort in the optimized dump as a way
of verifying that the call has not been eliminated from the program
regardless of their probabilities?
I think so, otherwise the call would be removed.
I'm going to test the patch (and eventually update scanned patterns).
Martin
Patch candidate:
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index b5e866d..de57e89 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -72,12 +72,17 @@ debug_gimple_stmt (gimple *gs)
print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
}
+/* Print format used for displaying probability of an edge or frequency
+ of a basic block. */
+
+#define PROBABILITY_FORMAT "[%.2f%%]"
+
/* Dump E probability to BUFFER. */
static void
dump_edge_probability (pretty_printer *buffer, edge e)
{
- pp_scalar (buffer, " [%.1f%%]",
+ pp_scalar (buffer, " " PROBABILITY_FORMAT,
e->probability * 100.0 / REG_BR_PROB_BASE);
}
@@ -1023,7 +1028,7 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
dump_generic_node (buffer, label, spc, flags, false);
basic_block bb = gimple_bb (gs);
if (bb && !(flags & TDF_GIMPLE))
- pp_scalar (buffer, " [%.1f%%]",
+ pp_scalar (buffer, " " PROBABILITY_FORMAT,
bb->frequency * 100.0 / REG_BR_PROB_BASE);
pp_colon (buffer);
}
@@ -2590,7 +2595,8 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int
indent, int flags)
if (flags & TDF_GIMPLE)
fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
else
- fprintf (outf, "%*s<bb %d> [%.1f%%]:\n", indent, "", bb->index,
+ fprintf (outf, "%*s<bb %d> " PROBABILITY_FORMAT ":\n",
+ indent, "", bb->index,
bb->frequency * 100.0 / REG_BR_PROB_BASE);
}
}
For reference, the directive the test uses since this change was
committed looks like this:
{ dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]:\n *__builtin_abort" 114
"optimized" }
If I'm reading the heavily escaped regex right it matches any
percentage, even 0.0% (and the test passes).
Thanks
Martin