]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cfgrtl: Don't crash in rtl_dump_bb if BB_END(bb) is NULL
authorSegher Boessenkool <segher@kernel.crashing.org>
Mon, 24 Jul 2017 19:47:15 +0000 (21:47 +0200)
committerSegher Boessenkool <segher@gcc.gnu.org>
Mon, 24 Jul 2017 19:47:15 +0000 (21:47 +0200)
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.

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

From-SVN: r250480

gcc/ChangeLog
gcc/cfgrtl.c

index e929c4d50d94bf1b25907ddf8958ffc4a791269c..897c605701db9e0cc30d8cf8f629747bbb772f48 100644 (file)
@@ -1,3 +1,7 @@
+2017-07-24  Segher Boessenkool  <segher@kernel.crashing.org>
+
+       * cfgrtl.c (rtl_dump_bb): Don't call NEXT_INSN on NULL.
+
 2017-07-24  Wilco Dijkstra  <wdijkstr@arm.com>
 
        PR target/79041
index 58d87fe09aeec97cc5d0f34c7f7f2bc48018e20e..6ef47b7e61f4f46684ef3ca99289104e2298215f 100644 (file)
@@ -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))
     {