diff mbox

Print Pass Names

Message ID BLU179-W66AA94FC7200624A62DF54B6C00@phx.gbl
State New
Headers show

Commit Message

Aditya K May 22, 2015, 4:32 p.m. UTC
Currently, when we print the passes it does not print its name. This becomes confusing when we want to print all the passes at once (e.g., -fdump-tree-all-all=stderr &> pass.dump).
This patch adds functionality to print the pass name. It passes bootstrap (with default configurations).

Hope this is useful.

Thanks,
-Aditya


gcc/ChangeLog:
 
2015-05-22  Aditya Kumar  <hiraditya@msn.com>
 
        * passes.c (execute_todo): Added a parameter to pass the pass name.
        (execute_one_pass): Likewise
        * statistics.c (statistics_fini_pass): Likewise
        * statistics.h: Likewise

---
 gcc/passes.c     | 9 +++++----
 gcc/statistics.c | 4 ++--
 gcc/statistics.h | 2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

Comments

Richard Biener May 22, 2015, 7:32 p.m. UTC | #1
On May 22, 2015 6:32:38 PM GMT+02:00, Aditya K <hiraditya@msn.com> wrote:
>Currently, when we print the passes it does not print its name. This
>becomes confusing when we want to print all the passes at once (e.g.,
>-fdump-tree-all-all=stderr &> pass.dump).
>This patch adds functionality to print the pass name. It passes
>bootstrap (with default configurations).
>
>Hope this is useful.

Can't you just use current_pass->name?

Richard.

>Thanks,
>-Aditya
>
>
>gcc/ChangeLog:
> 
>2015-05-22  Aditya Kumar  <hiraditya@msn.com>
> 
>    * passes.c (execute_todo): Added a parameter to pass the pass name.
>        (execute_one_pass): Likewise
>        * statistics.c (statistics_fini_pass): Likewise
>        * statistics.h: Likewise
>
>---
> gcc/passes.c     | 9 +++++----
> gcc/statistics.c | 4 ++--
> gcc/statistics.h | 2 +-
> 3 files changed, 8 insertions(+), 7 deletions(-)
> 
>diff --git a/gcc/passes.c b/gcc/passes.c
>index 04ff042..7d41bd8 100644
>--- a/gcc/passes.c
>+++ b/gcc/passes.c
>@@ -1984,7 +1984,7 @@ execute_function_todo (function *fn, void *data)
> 
> /* Perform all TODO actions.  */
> static void
>-execute_todo (unsigned int flags)
>+execute_todo (unsigned int flags, const char *pass_name=NULL)
> {
> #if defined ENABLE_CHECKING
>   if (cfun
>@@ -1997,7 +1997,7 @@ execute_todo (unsigned int flags)
>   /* Inform the pass whether it is the first time it is run.  */
>   first_pass_instance = (flags & TODO_mark_first_instance) != 0;
> 
>-  statistics_fini_pass ();
>+  statistics_fini_pass (pass_name);
> 
>   if (flags)
>     do_per_function (execute_function_todo, (void *)(size_t) flags);
>@@ -2302,7 +2302,7 @@ execute_one_pass (opt_pass *pass)
>   pass_init_dump_file (pass);
> 
>   /* Run pre-pass verification.  */
>-  execute_todo (pass->todo_flags_start);
>+  execute_todo (pass->todo_flags_start, pass->name);
> 
> #ifdef ENABLE_CHECKING
>   do_per_function (verify_curr_properties,
>@@ -2327,7 +2327,8 @@ execute_one_pass (opt_pass *pass)
>     check_profile_consistency (pass->static_pass_number, 0, true);
> 
>   /* Run post-pass cleanup and verification.  */
>-  execute_todo (todo_after | pass->todo_flags_finish |
>TODO_verify_il);
>+  execute_todo (todo_after | pass->todo_flags_finish | TODO_verify_il,
>+                pass->name);
>   if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
>     check_profile_consistency (pass->static_pass_number, 1, true);
> 
>diff --git a/gcc/statistics.c b/gcc/statistics.c
>index 8cbe88d..54f81d5 100644
>--- a/gcc/statistics.c
>+++ b/gcc/statistics.c
>@@ -192,7 +192,7 @@ statistics_fini_pass_3 (statistics_counter_t
>**slot,
> /* Dump the current statistics incrementally.  */
> 
> void
>-statistics_fini_pass (void)
>+statistics_fini_pass (const char *pass_name)
> {
>   if (current_pass->static_pass_number == -1)
>     return;
>@@ -201,7 +201,7 @@ statistics_fini_pass (void)
>       && dump_flags & TDF_STATS)
>     {
>       fprintf (dump_file, "\n");
>-      fprintf (dump_file, "Pass statistics:\n");
>+      fprintf (dump_file, "Pass statistics of \"%s\":\n", pass_name);
>       fprintf (dump_file, "----------------\n");
>       curr_statistics_hash ()
> 	->traverse_noresize <void *, statistics_fini_pass_1> (NULL);
>diff --git a/gcc/statistics.h b/gcc/statistics.h
>index 0b871ec..4348b7a 100644
>--- a/gcc/statistics.h
>+++ b/gcc/statistics.h
>@@ -64,7 +64,7 @@ struct function;
> extern void statistics_early_init (void);
> extern void statistics_init (void);
> extern void statistics_fini (void);
>-extern void statistics_fini_pass (void);
>+extern void statistics_fini_pass (const char *pass_name = NULL);
>extern void statistics_counter_event (struct function *, const char *,
>int);
>extern void statistics_histogram_event (struct function *, const char
>*, int);
>
diff mbox

Patch

diff --git a/gcc/passes.c b/gcc/passes.c
index 04ff042..7d41bd8 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1984,7 +1984,7 @@  execute_function_todo (function *fn, void *data)
 
 /* Perform all TODO actions.  */
 static void
-execute_todo (unsigned int flags)
+execute_todo (unsigned int flags, const char *pass_name=NULL)
 {
 #if defined ENABLE_CHECKING
   if (cfun
@@ -1997,7 +1997,7 @@  execute_todo (unsigned int flags)
   /* Inform the pass whether it is the first time it is run.  */
   first_pass_instance = (flags & TODO_mark_first_instance) != 0;
 
-  statistics_fini_pass ();
+  statistics_fini_pass (pass_name);
 
   if (flags)
     do_per_function (execute_function_todo, (void *)(size_t) flags);
@@ -2302,7 +2302,7 @@  execute_one_pass (opt_pass *pass)
   pass_init_dump_file (pass);
 
   /* Run pre-pass verification.  */
-  execute_todo (pass->todo_flags_start);
+  execute_todo (pass->todo_flags_start, pass->name);
 
 #ifdef ENABLE_CHECKING
   do_per_function (verify_curr_properties,
@@ -2327,7 +2327,8 @@  execute_one_pass (opt_pass *pass)
     check_profile_consistency (pass->static_pass_number, 0, true);
 
   /* Run post-pass cleanup and verification.  */
-  execute_todo (todo_after | pass->todo_flags_finish | TODO_verify_il);
+  execute_todo (todo_after | pass->todo_flags_finish | TODO_verify_il,
+                pass->name);
   if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
     check_profile_consistency (pass->static_pass_number, 1, true);
 
diff --git a/gcc/statistics.c b/gcc/statistics.c
index 8cbe88d..54f81d5 100644
--- a/gcc/statistics.c
+++ b/gcc/statistics.c
@@ -192,7 +192,7 @@  statistics_fini_pass_3 (statistics_counter_t **slot,
 /* Dump the current statistics incrementally.  */
 
 void
-statistics_fini_pass (void)
+statistics_fini_pass (const char *pass_name)
 {
   if (current_pass->static_pass_number == -1)
     return;
@@ -201,7 +201,7 @@  statistics_fini_pass (void)
       && dump_flags & TDF_STATS)
     {
       fprintf (dump_file, "\n");
-      fprintf (dump_file, "Pass statistics:\n");
+      fprintf (dump_file, "Pass statistics of \"%s\":\n", pass_name);
       fprintf (dump_file, "----------------\n");
       curr_statistics_hash ()
 	->traverse_noresize <void *, statistics_fini_pass_1> (NULL);
diff --git a/gcc/statistics.h b/gcc/statistics.h
index 0b871ec..4348b7a 100644
--- a/gcc/statistics.h
+++ b/gcc/statistics.h
@@ -64,7 +64,7 @@  struct function;
 extern void statistics_early_init (void);
 extern void statistics_init (void);
 extern void statistics_fini (void);
-extern void statistics_fini_pass (void);
+extern void statistics_fini_pass (const char *pass_name = NULL);
 extern void statistics_counter_event (struct function *, const char *, int);
 extern void statistics_histogram_event (struct function *, const char *, int);