public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: Richard Biener <rguenther@suse.de>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jan Hubicka <hubicka@ucw.cz>
Subject: [PATCH, PR70161] Fix fdump-ipa-all-graph
Date: Mon, 14 Mar 2016 15:33:00 -0000	[thread overview]
Message-ID: <56E6D97F.3030606@mentor.com> (raw)

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

Hi,

this patch fixes PR70161, a 4.9/5/6 regression.

Currently when using -fdump-ipa-all-graph, the compiler ICEs in 
execute_function_dump when testing for pass->graph_dump_initialized, 
because pass == NULL.

The patch fixes:
- the ICE by setting the pass argument in the call to
   execute_function_dump in execute_one_ipa_transform_pass
- a subsequent ICE (triggered with -fipa-pta) by saving, resetting and
   restoring dump_file_name in cgraph_node::get_body, alongside the
   saving and restoring of the dump_file variable.
- the duplicate edges in the subsequently generated dot file by
   ensuring that execute_function_dump is called only once per function
   per pass. [ Note that this bit also has an effect for the normal dump
   files for the ipa passes with transform function. For those functions,
   atm execute_function_dump is called both after execute and after
   transform. With the patch, it's only called after transform. ]

Bootstrapped and reg-tested on x86_64.

OK for stage4?

Thanks,
- Tom

[-- Attachment #2: 0002-Fix-fdump-ipa-all-graph.patch --]
[-- Type: text/x-patch, Size: 2449 bytes --]

Fix fdump-ipa-all-graph

2016-03-14  Tom de Vries  <tom@codesourcery.com>

	PR ipa/70161
	* cgraph.c (cgraph_node::get_body): Save, reset and restore
	dump_file_name.
	* passes.c (execute_one_ipa_transform_pass): Add missing argument to
	execute_function_dump.
	(execute_one_pass): Don't dump function if it will be dumped after ipa
	transform.

---
 gcc/cgraph.c |  3 +++
 gcc/passes.c | 14 +++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 7727313..f187913 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3365,7 +3365,9 @@ cgraph_node::get_body (void)
     {
       opt_pass *saved_current_pass = current_pass;
       FILE *saved_dump_file = dump_file;
+      const char *saved_dump_file_name = dump_file_name;
       int saved_dump_flags = dump_flags;
+      dump_file_name = NULL;
 
       push_cfun (DECL_STRUCT_FUNCTION (decl));
       execute_all_ipa_transforms ();
@@ -3377,6 +3379,7 @@ cgraph_node::get_body (void)
 
       current_pass = saved_current_pass;
       dump_file = saved_dump_file;
+      dump_file_name = saved_dump_file_name;
       dump_flags = saved_dump_flags;
     }
   return updated;
diff --git a/gcc/passes.c b/gcc/passes.c
index bbe35b3..5aa2b32 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -2219,7 +2219,7 @@ execute_one_ipa_transform_pass (struct cgraph_node *node,
     check_profile_consistency (pass->static_pass_number, 1, true);
 
   if (dump_file)
-    do_per_function (execute_function_dump, NULL);
+    do_per_function (execute_function_dump, pass);
   pass_fini_dump_file (pass);
 
   current_pass = NULL;
@@ -2356,15 +2356,15 @@ execute_one_pass (opt_pass *pass)
     check_profile_consistency (pass->static_pass_number, 1, true);
 
   verify_interpass_invariants ();
-  if (dump_file)
-    do_per_function (execute_function_dump, pass);
-  if (pass->type == IPA_PASS)
+  if (pass->type == IPA_PASS
+      && ((ipa_opt_pass_d *)pass)->function_transform)
     {
       struct cgraph_node *node;
-      if (((ipa_opt_pass_d *)pass)->function_transform)
-	FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
-	  node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *)pass);
+      FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
+	node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass_d *)pass);
     }
+  else if (dump_file)
+    do_per_function (execute_function_dump, pass);
 
   if (!current_function_decl)
     symtab->process_new_functions ();

             reply	other threads:[~2016-03-14 15:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14 15:33 Tom de Vries [this message]
2016-03-15 11:37 ` Richard Biener
2016-03-17 11:16   ` Tom de Vries
2016-03-17 11:19     ` Richard Biener
2016-03-18  9:33   ` Tom de Vries
2016-03-18  9:45     ` Tom de Vries
2016-04-17  6:09       ` [PING, testsuite] Add dot-file scan to test-case Tom de Vries
2016-04-18  7:30         ` Richard Biener
2016-04-18  7:59           ` Tom de Vries
2016-04-18  8:40             ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56E6D97F.3030606@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).