diff mbox series

Add debug_bb_details and debug_bb_n_details

Message ID 20201023093402.64062-1-luoxhu@linux.ibm.com
State New
Headers show
Series Add debug_bb_details and debug_bb_n_details | expand

Commit Message

Xionghu Luo Oct. 23, 2020, 9:34 a.m. UTC
Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
this debug_bb_details&debug_bb_n_details? Or any other similar call
existed?

gcc/ChangeLog:

2020-10-23  Xionghu Luo  <luoxhu@linux.ibm.com>

	* print-rtl.c (debug_bb_details): New function.
	* (debug_bb_n_details): New function.
---
 gcc/print-rtl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Segher Boessenkool Oct. 23, 2020, 9:57 a.m. UTC | #1
On Fri, Oct 23, 2020 at 04:34:02AM -0500, Xiong Hu Luo wrote:
> Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
> this debug_bb_details&debug_bb_n_details? Or any other similar call
> existed?

> +  dump_bb (stderr, bb, 0, TDF_DETAILS | TDF_BLOCKS);

You can just call this dump_bb directly?  And as a bonus you can dump it
to the dump file instead of to stderr ;-)


Segher
Richard Biener Oct. 23, 2020, 10:18 a.m. UTC | #2
On Fri, 23 Oct 2020, Xiong Hu Luo wrote:

> Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
> this debug_bb_details&debug_bb_n_details? Or any other similar call
> existed?

There's already debug_bb and debug_bb_n in cfg.c which works on both
RTL and GIMPLE.  How about instead adding overloads that accept
a flags argument so you can do

debug_bb_n (5, TDF_DETAILS)

?  The debug_bb_slim variant would then just a forwarder.

> gcc/ChangeLog:
> 
> 2020-10-23  Xionghu Luo  <luoxhu@linux.ibm.com>
> 
> 	* print-rtl.c (debug_bb_details): New function.
> 	* (debug_bb_n_details): New function.
> ---
>  gcc/print-rtl.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> index 25265efc71b..f45873b8863 100644
> --- a/gcc/print-rtl.c
> +++ b/gcc/print-rtl.c
> @@ -2150,6 +2150,21 @@ debug_bb_n_slim (int n)
>    debug_bb_slim (bb);
>  }
>  
> +extern void debug_bb_details (basic_block);
> +DEBUG_FUNCTION void
> +debug_bb_details (basic_block bb)
> +{
> +  dump_bb (stderr, bb, 0, TDF_DETAILS | TDF_BLOCKS);
> +}
> +
> +extern void debug_bb_n_details (int);
> +DEBUG_FUNCTION void
> +debug_bb_n_details (int n)
> +{
> +  basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
> +  debug_bb_details (bb);
> +}
> +
>  #endif
>  
>  #if __GNUC__ >= 10
>
Xionghu Luo Oct. 26, 2020, 2:53 a.m. UTC | #3
On 2020/10/23 18:18, Richard Biener wrote:
> On Fri, 23 Oct 2020, Xiong Hu Luo wrote:
> 
>> Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
>> this debug_bb_details&debug_bb_n_details? Or any other similar call
>> existed?
> There's already debug_bb and debug_bb_n in cfg.c which works on both
> RTL and GIMPLE.  How about instead adding overloads that accept
> a flags argument so you can do
> 
> debug_bb_n (5, TDF_DETAILS)
> 
> ?  The debug_bb_slim variant would then just a forwarder.
> 

Thanks.  Updated the patch as below:


[PATCH v2] Add overloaded debug_bb and debug_bb_n with dump flags


Add overloads that accept a flags argument so we can print
debug_bb_n (5, TDF_DETAILS) in gdb, also the debug_bb_slim
variant would then be just a forwarder.

gcc/ChangeLog:

2020-10-26  Xionghu Luo  <luoxhu@linux.ibm.com>

	* cfg.c (debug_bb): New overloaded function.
	(debug_bb_n): New overloaded function.
	* cfg.h (debug_bb_n): New declaration.
	(debug_bb_n): New declaration.
	* print-rtl.c (debug_bb_slim): Call debug_bb with flags.
---
 gcc/cfg.c       | 20 +++++++++++++++++++-
 gcc/cfg.h       |  2 ++
 gcc/print-rtl.c |  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/gcc/cfg.c b/gcc/cfg.c
index 270a48f729a..05f922f5470 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -720,7 +720,7 @@ free_aux_for_edges (void)
 DEBUG_FUNCTION void
 debug_bb (basic_block bb)
 {
-  dump_bb (stderr, bb, 0, dump_flags);
+  debug_bb (bb, dump_flags);
 }
 
 DEBUG_FUNCTION basic_block
@@ -731,6 +731,24 @@ debug_bb_n (int n)
   return bb;
 }
 
+/* Print bb with specified flags.  */
+
+DEBUG_FUNCTION void
+debug_bb (basic_block bb, dump_flags_t flags)
+{
+  dump_bb (stderr, bb, 0, flags);
+}
+
+/* Print bb numbered n with specified flags.  */
+
+DEBUG_FUNCTION basic_block
+debug_bb_n (int n, dump_flags_t flags)
+{
+  basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
+  debug_bb (bb, flags);
+  return bb;
+}
+
 /* Dumps cfg related information about basic block BB to OUTF.
    If HEADER is true, dump things that appear before the instructions
    contained in BB.  If FOOTER is true, dump things that appear after.
diff --git a/gcc/cfg.h b/gcc/cfg.h
index 1eb7866bac9..93fde6df2bf 100644
--- a/gcc/cfg.h
+++ b/gcc/cfg.h
@@ -108,6 +108,8 @@ extern void clear_aux_for_edges (void);
 extern void free_aux_for_edges (void);
 extern void debug_bb (basic_block);
 extern basic_block debug_bb_n (int);
+extern void debug_bb (basic_block, dump_flags_t);
+extern basic_block debug_bb_n (int, dump_flags_t);
 extern void dump_bb_info (FILE *, basic_block, int, dump_flags_t, bool, bool);
 extern void brief_dump_cfg (FILE *, dump_flags_t);
 extern void update_bb_profile_for_threading (basic_block, profile_count, edge);
diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index 25265efc71b..d514b1c5373 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -2139,7 +2139,7 @@ extern void debug_bb_slim (basic_block);
 DEBUG_FUNCTION void
 debug_bb_slim (basic_block bb)
 {
-  dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
+  debug_bb (bb, TDF_SLIM | TDF_BLOCKS);
 }
 
 extern void debug_bb_n_slim (int);
Richard Biener Oct. 26, 2020, 7:43 a.m. UTC | #4
On Mon, 26 Oct 2020, Xionghu Luo wrote:

> 
> On 2020/10/23 18:18, Richard Biener wrote:
> > On Fri, 23 Oct 2020, Xiong Hu Luo wrote:
> > 
> >> Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
> >> this debug_bb_details&debug_bb_n_details? Or any other similar call
> >> existed?
> > There's already debug_bb and debug_bb_n in cfg.c which works on both
> > RTL and GIMPLE.  How about instead adding overloads that accept
> > a flags argument so you can do
> > 
> > debug_bb_n (5, TDF_DETAILS)
> > 
> > ?  The debug_bb_slim variant would then just a forwarder.
> > 
> 
> Thanks.  Updated the patch as below:

OK.

Richard.

> 
> [PATCH v2] Add overloaded debug_bb and debug_bb_n with dump flags
> 
> 
> Add overloads that accept a flags argument so we can print
> debug_bb_n (5, TDF_DETAILS) in gdb, also the debug_bb_slim
> variant would then be just a forwarder.
> 
> gcc/ChangeLog:
> 
> 2020-10-26  Xionghu Luo  <luoxhu@linux.ibm.com>
> 
> 	* cfg.c (debug_bb): New overloaded function.
> 	(debug_bb_n): New overloaded function.
> 	* cfg.h (debug_bb_n): New declaration.
> 	(debug_bb_n): New declaration.
> 	* print-rtl.c (debug_bb_slim): Call debug_bb with flags.
> ---
>  gcc/cfg.c       | 20 +++++++++++++++++++-
>  gcc/cfg.h       |  2 ++
>  gcc/print-rtl.c |  2 +-
>  3 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/cfg.c b/gcc/cfg.c
> index 270a48f729a..05f922f5470 100644
> --- a/gcc/cfg.c
> +++ b/gcc/cfg.c
> @@ -720,7 +720,7 @@ free_aux_for_edges (void)
>  DEBUG_FUNCTION void
>  debug_bb (basic_block bb)
>  {
> -  dump_bb (stderr, bb, 0, dump_flags);
> +  debug_bb (bb, dump_flags);
>  }
>  
>  DEBUG_FUNCTION basic_block
> @@ -731,6 +731,24 @@ debug_bb_n (int n)
>    return bb;
>  }
>  
> +/* Print bb with specified flags.  */
> +
> +DEBUG_FUNCTION void
> +debug_bb (basic_block bb, dump_flags_t flags)
> +{
> +  dump_bb (stderr, bb, 0, flags);
> +}
> +
> +/* Print bb numbered n with specified flags.  */
> +
> +DEBUG_FUNCTION basic_block
> +debug_bb_n (int n, dump_flags_t flags)
> +{
> +  basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
> +  debug_bb (bb, flags);
> +  return bb;
> +}
> +
>  /* Dumps cfg related information about basic block BB to OUTF.
>     If HEADER is true, dump things that appear before the instructions
>     contained in BB.  If FOOTER is true, dump things that appear after.
> diff --git a/gcc/cfg.h b/gcc/cfg.h
> index 1eb7866bac9..93fde6df2bf 100644
> --- a/gcc/cfg.h
> +++ b/gcc/cfg.h
> @@ -108,6 +108,8 @@ extern void clear_aux_for_edges (void);
>  extern void free_aux_for_edges (void);
>  extern void debug_bb (basic_block);
>  extern basic_block debug_bb_n (int);
> +extern void debug_bb (basic_block, dump_flags_t);
> +extern basic_block debug_bb_n (int, dump_flags_t);
>  extern void dump_bb_info (FILE *, basic_block, int, dump_flags_t, bool, bool);
>  extern void brief_dump_cfg (FILE *, dump_flags_t);
>  extern void update_bb_profile_for_threading (basic_block, profile_count, edge);
> diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> index 25265efc71b..d514b1c5373 100644
> --- a/gcc/print-rtl.c
> +++ b/gcc/print-rtl.c
> @@ -2139,7 +2139,7 @@ extern void debug_bb_slim (basic_block);
>  DEBUG_FUNCTION void
>  debug_bb_slim (basic_block bb)
>  {
> -  dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
> +  debug_bb (bb, TDF_SLIM | TDF_BLOCKS);
>  }
>  
>  extern void debug_bb_n_slim (int);
>
diff mbox series

Patch

diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index 25265efc71b..f45873b8863 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -2150,6 +2150,21 @@  debug_bb_n_slim (int n)
   debug_bb_slim (bb);
 }
 
+extern void debug_bb_details (basic_block);
+DEBUG_FUNCTION void
+debug_bb_details (basic_block bb)
+{
+  dump_bb (stderr, bb, 0, TDF_DETAILS | TDF_BLOCKS);
+}
+
+extern void debug_bb_n_details (int);
+DEBUG_FUNCTION void
+debug_bb_n_details (int n)
+{
+  basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
+  debug_bb_details (bb);
+}
+
 #endif
 
 #if __GNUC__ >= 10