Hi. Following simple patch adds support for dumping of BBs when it's a BB that contains a label. That makes it easier for debugging as one can find destination for an edge in dump file.
Sample, before: foo (int a) { int D.1821; int _1; int _4; int _5; <bb 2> [0.00%] [count: INV]: switch (a_2(D)) <default: <L2> [INV] [count: INV], case 0: <L0> [INV] [count: INV], case 1: <L1> [INV] [count: INV]> <L0> [0.00%] [count: INV]: a_3 = a_2(D) + 2; <L1> [0.00%] [count: INV]: _4 = 2; goto <bb 6> (<L3>); [INV] [count: INV] <L2> [0.00%] [count: INV]: _5 = 123; # _1 = PHI <_4(4), _5(5)> <L3> [0.00%] [count: INV]: return _1; } After: foo (int a) { int D.1821; int _1; int _4; int _5; <bb 2> [0.00%] [count: INV]: switch (a_2(D)) <default: <L2> [INV] [count: INV], case 0: <L0> [INV] [count: INV], case 1: <L1> [INV] [count: INV]> <L0> (<bb 3>) [0.00%] [count: INV]: a_3 = a_2(D) + 2; <L1> (<bb 4>) [0.00%] [count: INV]: _4 = 2; goto <bb 6> (<L3>); [INV] [count: INV] <L2> (<bb 5>) [0.00%] [count: INV]: _5 = 123; # _1 = PHI <_4(4), _5(5)> <L3> (<bb 6>) [0.00%] [count: INV]: return _1; } Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Thoughts? Martin gcc/testsuite/ChangeLog: 2017-07-27 Martin Liska <mli...@suse.cz> * gcc.dg/builtin-unreachable-6.c: Update scanned pattern. * gcc.dg/tree-ssa/attr-hotcold-2.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-18.c: Likewise. gcc/ChangeLog: 2017-07-27 Martin Liska <mli...@suse.cz> * gimple-pretty-print.c (dump_gimple_label): Dump BB number. --- gcc/gimple-pretty-print.c | 6 +++++- gcc/testsuite/gcc.dg/builtin-unreachable-6.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c | 4 ++-- gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-18.c | 3 +-- 4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index c8eb9c4a7bf..6b272286714 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1122,7 +1122,11 @@ 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_profile (bb->frequency, bb->count)); + { + if (gimple_bb (gs)) + pp_scalar (buffer, " (<bb %d>)", gimple_bb (gs)->index); + pp_scalar (buffer, " %s", dump_profile (bb->frequency, bb->count)); + } pp_colon (buffer); } if (flags & TDF_GIMPLE) diff --git a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c index d2596e95c3f..040917f29b0 100644 --- a/gcc/testsuite/gcc.dg/builtin-unreachable-6.c +++ b/gcc/testsuite/gcc.dg/builtin-unreachable-6.c @@ -16,5 +16,5 @@ lab2: goto *x; } -/* { dg-final { scan-tree-dump-times "lab \\\[\[0-9.\]+%\\\]" 1 "fab1" } } */ +/* { dg-final { scan-tree-dump-times "lab \\\(<bb .>\\\) \\\[\[0-9.\]+%\\\]" 1 "fab1" } } */ /* { dg-final { scan-tree-dump-times "__builtin_unreachable" 1 "fab1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c index 184dd10ddae..67eb9163684 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c @@ -20,9 +20,9 @@ void f(int x, int y) /* { dg-final { scan-tree-dump-times "hot label heuristics" 1 "profile_estimate" } } */ /* { dg-final { scan-tree-dump-times "cold label heuristics" 1 "profile_estimate" } } */ -/* { dg-final { scan-tree-dump "A \\\[0\\\..*\\\]" "profile_estimate" } } */ +/* { dg-final { scan-tree-dump "A \\\(<bb .>\\\) \\\[0\\\..*\\\]" "profile_estimate" } } */ /* Note: we're attempting to match some number > 6000, i.e. > 60%. The exact number ought to be tweekable without having to juggle the testcase around too much. */ -/* { dg-final { scan-tree-dump "B \\\[\[6-9\]\[0-9\]\\\..*\\\]" "profile_estimate" } } */ +/* { dg-final { scan-tree-dump "B \\\(<bb .>\\\) \\\[\[6-9\]\[0-9\]\\\..*\\\]" "profile_estimate" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-18.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-18.c index 2ab12626088..78d53520395 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-18.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-18.c @@ -15,5 +15,4 @@ void func2(int* val) d: d(val); } -/* { dg-final { scan-tree-dump-not "a \\\(" "ccp1" } } */ -/* { dg-final { scan-tree-dump-not "b \\\(" "ccp1" } } */ +/* { dg-final { scan-tree-dump-not "goto" "ccp1" } } */