public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL
@ 2017-07-24 13:54 Segher Boessenkool
  2017-07-24 13:54 ` [PATCH 2/2] passes: Print a header in emergency_dump_function Segher Boessenkool
  2017-07-24 18:26 ` [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL Richard Biener
  0 siblings, 2 replies; 4+ messages in thread
From: Segher Boessenkool @ 2017-07-24 13:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool

Currently rtl_dump_bb crashes if BB_END(bb) is NULL, like it can be
during expand (rtl_dump_bb can be called at any time, by the emergency
dump added recently for example).

This fixes it.


Segher


2017-07-24  Segher Boessenkool  <segher@kernel.crashing.org>

	* gcc/cfgrtl.c (rtl_dump_bb): Don't call NEXT_INSN on NULL.

---
 gcc/cfgrtl.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 58d87fe..6ef47b7 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2109,8 +2109,6 @@ commit_edge_insertions (void)
 static void
 rtl_dump_bb (FILE *outf, basic_block bb, int indent, dump_flags_t flags)
 {
-  rtx_insn *insn;
-  rtx_insn *last;
   char *s_indent;
 
   s_indent = (char *) alloca ((size_t) indent + 1);
@@ -2124,18 +2122,22 @@ rtl_dump_bb (FILE *outf, basic_block bb, int indent, dump_flags_t flags)
     }
 
   if (bb->index != ENTRY_BLOCK && bb->index != EXIT_BLOCK)
-    for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb)); insn != last;
-	 insn = NEXT_INSN (insn))
-      {
-	if (flags & TDF_DETAILS)
-	  df_dump_insn_top (insn, outf);
-	if (! (flags & TDF_SLIM))
-	  print_rtl_single (outf, insn);
-	else
-	  dump_insn_slim (outf, insn);
-	if (flags & TDF_DETAILS)
-	  df_dump_insn_bottom (insn, outf);
-      }
+    {
+      rtx_insn *last = BB_END (bb);
+      if (last)
+	last = NEXT_INSN (last);
+      for (rtx_insn *insn = BB_HEAD (bb); insn != last; insn = NEXT_INSN (insn))
+	{
+	  if (flags & TDF_DETAILS)
+	    df_dump_insn_top (insn, outf);
+	  if (! (flags & TDF_SLIM))
+	    print_rtl_single (outf, insn);
+	  else
+	    dump_insn_slim (outf, insn);
+	  if (flags & TDF_DETAILS)
+	    df_dump_insn_bottom (insn, outf);
+	}
+    }
 
   if (df && (flags & TDF_DETAILS))
     {
-- 
1.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] passes: Print a header in emergency_dump_function
  2017-07-24 13:54 [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL Segher Boessenkool
@ 2017-07-24 13:54 ` Segher Boessenkool
  2017-07-24 18:27   ` Richard Biener
  2017-07-24 18:26 ` [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL Richard Biener
  1 sibling, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2017-07-24 13:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool

Currently the emergency dump has no separation whatsoever from any
previous output in the dump file, making it harder than necessary
to find.


Segher


2017-07-24  Segher Boessenkool  <segher@kernel.crashing.org>

	* passes.c (emergency_dump_function): Print some empty lines and a
	header before the RTL dump.

---
 gcc/passes.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/passes.c b/gcc/passes.c
index 374f6f7..f5791ac 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1796,6 +1796,7 @@ emergency_dump_function ()
   if (!dump_file || !cfun)
     return;
   fnotice (stderr, "dump file: %s\n", dump_file_name);
+  fprintf (dump_file, "\n\n\nEMERGENCY DUMP:\n\n");
   execute_function_dump (cfun, current_pass);
 }
 
-- 
1.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL
  2017-07-24 13:54 [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL Segher Boessenkool
  2017-07-24 13:54 ` [PATCH 2/2] passes: Print a header in emergency_dump_function Segher Boessenkool
@ 2017-07-24 18:26 ` Richard Biener
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Biener @ 2017-07-24 18:26 UTC (permalink / raw)
  To: gcc-patches, Segher Boessenkool

On July 24, 2017 3:54:05 PM GMT+02:00, Segher Boessenkool <segher@kernel.crashing.org> wrote:
>Currently rtl_dump_bb crashes if BB_END(bb) is NULL, like it can be
>during expand (rtl_dump_bb can be called at any time, by the emergency
>dump added recently for example).

Ick.

>This fixes it.

OK.

Richard.

>
>Segher
>
>
>2017-07-24  Segher Boessenkool  <segher@kernel.crashing.org>
>
>	* gcc/cfgrtl.c (rtl_dump_bb): Don't call NEXT_INSN on NULL.
>
>---
> gcc/cfgrtl.c | 30 ++++++++++++++++--------------
> 1 file changed, 16 insertions(+), 14 deletions(-)
>
>diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
>index 58d87fe..6ef47b7 100644
>--- a/gcc/cfgrtl.c
>+++ b/gcc/cfgrtl.c
>@@ -2109,8 +2109,6 @@ commit_edge_insertions (void)
> static void
>rtl_dump_bb (FILE *outf, basic_block bb, int indent, dump_flags_t
>flags)
> {
>-  rtx_insn *insn;
>-  rtx_insn *last;
>   char *s_indent;
> 
>   s_indent = (char *) alloca ((size_t) indent + 1);
>@@ -2124,18 +2122,22 @@ rtl_dump_bb (FILE *outf, basic_block bb, int
>indent, dump_flags_t flags)
>     }
> 
>   if (bb->index != ENTRY_BLOCK && bb->index != EXIT_BLOCK)
>-    for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb)); insn !=
>last;
>-	 insn = NEXT_INSN (insn))
>-      {
>-	if (flags & TDF_DETAILS)
>-	  df_dump_insn_top (insn, outf);
>-	if (! (flags & TDF_SLIM))
>-	  print_rtl_single (outf, insn);
>-	else
>-	  dump_insn_slim (outf, insn);
>-	if (flags & TDF_DETAILS)
>-	  df_dump_insn_bottom (insn, outf);
>-      }
>+    {
>+      rtx_insn *last = BB_END (bb);
>+      if (last)
>+	last = NEXT_INSN (last);
>+      for (rtx_insn *insn = BB_HEAD (bb); insn != last; insn =
>NEXT_INSN (insn))
>+	{
>+	  if (flags & TDF_DETAILS)
>+	    df_dump_insn_top (insn, outf);
>+	  if (! (flags & TDF_SLIM))
>+	    print_rtl_single (outf, insn);
>+	  else
>+	    dump_insn_slim (outf, insn);
>+	  if (flags & TDF_DETAILS)
>+	    df_dump_insn_bottom (insn, outf);
>+	}
>+    }
> 
>   if (df && (flags & TDF_DETAILS))
>     {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] passes: Print a header in emergency_dump_function
  2017-07-24 13:54 ` [PATCH 2/2] passes: Print a header in emergency_dump_function Segher Boessenkool
@ 2017-07-24 18:27   ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2017-07-24 18:27 UTC (permalink / raw)
  To: gcc-patches, Segher Boessenkool

On July 24, 2017 3:54:06 PM GMT+02:00, Segher Boessenkool <segher@kernel.crashing.org> wrote:
>Currently the emergency dump has no separation whatsoever from any
>previous output in the dump file, making it harder than necessary
>to find.

OK.

>
>Segher
>
>
>2017-07-24  Segher Boessenkool  <segher@kernel.crashing.org>
>
>	* passes.c (emergency_dump_function): Print some empty lines and a
>	header before the RTL dump.
>
>---
> gcc/passes.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/gcc/passes.c b/gcc/passes.c
>index 374f6f7..f5791ac 100644
>--- a/gcc/passes.c
>+++ b/gcc/passes.c
>@@ -1796,6 +1796,7 @@ emergency_dump_function ()
>   if (!dump_file || !cfun)
>     return;
>   fnotice (stderr, "dump file: %s\n", dump_file_name);
>+  fprintf (dump_file, "\n\n\nEMERGENCY DUMP:\n\n");
>   execute_function_dump (cfun, current_pass);
> }
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-24 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-24 13:54 [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL Segher Boessenkool
2017-07-24 13:54 ` [PATCH 2/2] passes: Print a header in emergency_dump_function Segher Boessenkool
2017-07-24 18:27   ` Richard Biener
2017-07-24 18:26 ` [PATCH 1/2] cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).