From e57c896e86c4257741b574d99d7cacbfda219755 Mon Sep 17 00:00:00 2001
From: Richard Biener <rguenther@suse.de>
Date: Thu, 4 Jul 2019 13:56:12 +0000
Subject: [PATCH] re PR ipa/91062 (gcc.dg/ipa/ipa-pta-1.c dump contains garbage
 when gcc was configured with --enable-checking=all)

2019-07-04  Richard Biener  <rguenther@suse.de>

	PR ipa/91062
	* tree-pass.h (execute_all_ipa_transforms): Add a flag
	parameter whether to disable GC collection.
	* passes.c (execute_one_ipa_transform_pass): Likewise, and
	honor it.
	(execute_all_ipa_transforms): Likewise and pass it down.
	* cgraph.c (cgraph_node::get_body): Do not invoke garbage
	collection from applying IPA transforms.
	* cgraphunit.c (cgraph_node::expand): Allow garbage collection
	from applying IPA transforms.

From-SVN: r273083
---
 gcc/ChangeLog    | 13 +++++++++++++
 gcc/cgraph.c     |  2 +-
 gcc/cgraphunit.c |  2 +-
 gcc/passes.c     |  9 +++++----
 gcc/tree-pass.h  |  2 +-
 5 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 591e2972a169..19ab956a98cf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2019-07-04  Richard Biener  <rguenther@suse.de>
+
+	PR ipa/91062
+	* tree-pass.h (execute_all_ipa_transforms): Add a flag
+	parameter whether to disable GC collection.
+	* passes.c (execute_one_ipa_transform_pass): Likewise, and
+	honor it.
+	(execute_all_ipa_transforms): Likewise and pass it down.
+	* cgraph.c (cgraph_node::get_body): Do not invoke garbage
+	collection from applying IPA transforms.
+	* cgraphunit.c (cgraph_node::expand): Allow garbage collection
+	from applying IPA transforms.
+
 2019-07-04  Richard Biener  <rguenther@suse.de>
 
 	PR tree-optimization/90911
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d161db96f14d..a7e3bcf21326 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3618,7 +3618,7 @@ cgraph_node::get_body (void)
       set_dump_file (NULL);
 
       push_cfun (DECL_STRUCT_FUNCTION (decl));
-      execute_all_ipa_transforms ();
+      execute_all_ipa_transforms (true);
       cgraph_edge::rebuild_edges ();
       free_dominance_info (CDI_DOMINATORS);
       free_dominance_info (CDI_POST_DOMINATORS);
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index f4d668819c62..5999b9e0de8d 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2184,7 +2184,7 @@ cgraph_node::expand (void)
 
   bitmap_obstack_initialize (&reg_obstack); /* FIXME, only at RTL generation*/
 
-  execute_all_ipa_transforms ();
+  execute_all_ipa_transforms (false);
 
   /* Perform all tree transforms and optimizations.  */
 
diff --git a/gcc/passes.c b/gcc/passes.c
index c6331cbc49db..bd56004d909b 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -2182,7 +2182,7 @@ execute_ipa_summary_passes (ipa_opt_pass_d *ipa_pass)
 
 static void
 execute_one_ipa_transform_pass (struct cgraph_node *node,
-				ipa_opt_pass_d *ipa_pass)
+				ipa_opt_pass_d *ipa_pass, bool do_not_collect)
 {
   opt_pass *pass = ipa_pass;
   unsigned int todo_after = 0;
@@ -2228,14 +2228,14 @@ execute_one_ipa_transform_pass (struct cgraph_node *node,
   redirect_edge_var_map_empty ();
 
   /* Signal this is a suitable GC collection point.  */
-  if (!(todo_after & TODO_do_not_ggc_collect))
+  if (!do_not_collect && !(todo_after & TODO_do_not_ggc_collect))
     ggc_collect ();
 }
 
 /* For the current function, execute all ipa transforms. */
 
 void
-execute_all_ipa_transforms (void)
+execute_all_ipa_transforms (bool do_not_collect)
 {
   struct cgraph_node *node;
   if (!cfun)
@@ -2247,7 +2247,8 @@ execute_all_ipa_transforms (void)
       unsigned int i;
 
       for (i = 0; i < node->ipa_transforms_to_apply.length (); i++)
-	execute_one_ipa_transform_pass (node, node->ipa_transforms_to_apply[i]);
+	execute_one_ipa_transform_pass (node, node->ipa_transforms_to_apply[i],
+					do_not_collect);
       node->ipa_transforms_to_apply.release ();
     }
 }
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index 3a0b3805d24d..b27dbdd0cb7d 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -632,7 +632,7 @@ extern bool execute_one_pass (opt_pass *);
 extern void execute_pass_list (function *, opt_pass *);
 extern void execute_ipa_pass_list (opt_pass *);
 extern void execute_ipa_summary_passes (ipa_opt_pass_d *);
-extern void execute_all_ipa_transforms (void);
+extern void execute_all_ipa_transforms (bool);
 extern void execute_all_ipa_stmt_fixups (struct cgraph_node *, gimple **);
 extern bool pass_init_dump_file (opt_pass *);
 extern void pass_fini_dump_file (opt_pass *);
-- 
GitLab