public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]middle-end: On emergency dumps finish the graph generation.
@ 2023-03-07 17:38 Tamar Christina
  2023-03-08  7:22 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Tamar Christina @ 2023-03-07 17:38 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd, rguenther, jlaw

[-- Attachment #1: Type: text/plain, Size: 1547 bytes --]

Hi All,

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.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

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

--- inline copy of patch -- 
diff --git a/gcc/passes.cc b/gcc/passes.cc
index 347214e81d0cfac05d9ba782db0eda1cdd7e9c87..38642a4010941b414a1ed1fd70a348778addbf60 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -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);
 }




-- 

[-- Attachment #2: rb17094.patch --]
[-- Type: text/plain, Size: 757 bytes --]

diff --git a/gcc/passes.cc b/gcc/passes.cc
index 347214e81d0cfac05d9ba782db0eda1cdd7e9c87..38642a4010941b414a1ed1fd70a348778addbf60 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -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);
 }




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

* Re: [PATCH]middle-end: On emergency dumps finish the graph generation.
  2023-03-07 17:38 [PATCH]middle-end: On emergency dumps finish the graph generation Tamar Christina
@ 2023-03-08  7:22 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-03-08  7:22 UTC (permalink / raw)
  To: Tamar Christina; +Cc: gcc-patches, nd, jlaw

On Tue, 7 Mar 2023, Tamar Christina wrote:

> Hi All,
> 
> 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.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> 
> Ok for master?

OK.

> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	* passes.cc (emergency_dump_function): Finish graph generation.
> 
> --- inline copy of patch -- 
> diff --git a/gcc/passes.cc b/gcc/passes.cc
> index 347214e81d0cfac05d9ba782db0eda1cdd7e9c87..38642a4010941b414a1ed1fd70a348778addbf60 100644
> --- a/gcc/passes.cc
> +++ b/gcc/passes.cc
> @@ -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);
>  }
> 
> 
> 
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

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

end of thread, other threads:[~2023-03-08  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 17:38 [PATCH]middle-end: On emergency dumps finish the graph generation Tamar Christina
2023-03-08  7:22 ` 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).