[tree-ssa-loop-ch] Add missing NULL test for dump_file
authorTom de Vries <tdevries@suse.de>
Wed, 7 Oct 2020 05:22:43 +0000 (07:22 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 7 Oct 2020 06:06:47 +0000 (08:06 +0200)
If we change gimple_can_duplicate_bb_p to return false instead of true, we run
into a segfault in ch_base::copy_headers due to using dump_file while it's
NULL:
...
      if (!gimple_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs,
                                        true))
       {
         fprintf (dump_file, "Duplication failed.\n");
         continue;
       }
...

Fix this by adding the missing dump_file != NULL test.

Tested by rebuilding lto1 and rerunning the failing test-case.

gcc/ChangeLog:

2020-10-07  Tom de Vries  <tdevries@suse.de>

* tree-ssa-loop-ch.c (ch_base::copy_headers): Add missing NULL test
for dump_file.

gcc/tree-ssa-loop-ch.c

index b86acf7c39dd660b92c1850349b71e70cd63d043..1f3d9321a55fbc5496134db16240678c8a7a9a3e 100644 (file)
@@ -425,7 +425,8 @@ ch_base::copy_headers (function *fun)
       if (!gimple_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs,
                                         true))
        {
-         fprintf (dump_file, "Duplication failed.\n");
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           fprintf (dump_file, "Duplication failed.\n");
          continue;
        }
       copied.safe_push (std::make_pair (entry, loop));