]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: On emergency dumps finish the graph generation.
authorTamar Christina <tamar.christina@arm.com>
Thu, 9 Mar 2023 19:43:08 +0000 (19:43 +0000)
committerTamar Christina <tamar.christina@arm.com>
Thu, 9 Mar 2023 19:43:08 +0000 (19:43 +0000)
When doing an emergency dump the cfg output dumps are corrupted because the
ending "}" is missing.

Normally when the pass manager finishes it would call finish_graph_dump_file to
produce this.  This is called here because each pass can dump multiple digraphs.

However during an emergency dump we only dump the current function and so after
that is done we never go back to the pass manager.

As such, we need to manually call finish_graph_dump_file in order to properly
finish off graph generation.

With this -ftree-dump-*-graph works properly during a crash dump.

gcc/ChangeLog:

* passes.cc (emergency_dump_function): Finish graph generation.

gcc/passes.cc

index 91d560720c3d9988d6427671934c79a26961939f..2f0e378b8b2c02fc278f1e48346a0444e5cfbf39 100644 (file)
@@ -1845,6 +1845,13 @@ emergency_dump_function ()
   fprintf (dump_file, "\n\n\nEMERGENCY DUMP:\n\n");
   execute_function_dump (cfun, current_pass);
 
+  /* Normally the passmanager will close the graphs as a pass could be wanting
+     to print multiple digraphs. But during an emergency dump there can only be
+     one and we must finish the graph manually.  */
+  if ((cfun->curr_properties & PROP_cfg)
+      && (dump_flags & TDF_GRAPH))
+    finish_graph_dump_file (dump_file_name);
+
   if (symtab && current_pass->type == IPA_PASS)
     symtab->dump (dump_file);
 }