public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR60911
@ 2014-04-24 11:42 Richard Biener
  2014-04-24 14:37 ` Jan Hubicka
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2014-04-24 11:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka


Simple IPA passes are supposed to see function bodies with IPA transforms 
applied - this is what the code in execute_one_pass tries to ensure.
But that doesn't work anymore with on-demand function-body loading.
The following addresses this in the least intrusive way - inlining
do_per_function (apply_ipa_transforms) and adjusting it accordingly.

This IMHO is definitely the solution for the 4.9 branch (and for
the time being on trunk).

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Ok for trunk and branch?

Thanks,
Richard.

2014-04-24  Richard Biener  <rguenther@suse.de>

	PR ipa/60911
	* passes.c (apply_ipa_transforms): Inline into only caller ...
	(execute_one_pass): ... here.  Properly bring in function
	bodies for nodes we want to apply IPA transforms to.

	* gcc.dg/lto/pr60911_0.c: New testcase.

Index: gcc/passes.c
===================================================================
--- gcc/passes.c	(revision 209742)
+++ gcc/passes.c	(working copy)
@@ -2109,20 +2109,6 @@ execute_all_ipa_transforms (void)
     }
 }
 
-/* Callback for do_per_function to apply all IPA transforms.  */
-
-static void
-apply_ipa_transforms (void *data)
-{
-  struct cgraph_node *node = cgraph_get_node (current_function_decl);
-  if (!node->global.inlined_to && node->ipa_transforms_to_apply.exists ())
-    {
-      *(bool *)data = true;
-      execute_all_ipa_transforms ();
-      rebuild_cgraph_edges ();
-    }
-}
-
 /* Check if PASS is explicitly disabled or enabled and return
    the gate status.  FUNC is the function to be processed, and
    GATE_STATUS is the gate status determined by pass manager by
@@ -2194,8 +2180,26 @@ execute_one_pass (opt_pass *pass)
      Apply all trnasforms first.  */
   if (pass->type == SIMPLE_IPA_PASS)
     {
+      struct cgraph_node *node;
       bool applied = false;
-      do_per_function (apply_ipa_transforms, (void *)&applied);
+      FOR_EACH_DEFINED_FUNCTION (node)
+	if (node->analyzed
+	    && cgraph_function_with_gimple_body_p (node)
+	    && (!node->clone_of || node->decl != node->clone_of->decl))
+	  {
+	    if (!node->global.inlined_to
+		&& node->ipa_transforms_to_apply.exists ())
+	      {
+		cgraph_get_body (node);
+		push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+		execute_all_ipa_transforms ();
+		rebuild_cgraph_edges ();
+		free_dominance_info (CDI_DOMINATORS);
+		free_dominance_info (CDI_POST_DOMINATORS);
+		pop_cfun ();
+		applied = true;
+	      }
+	  }
       if (applied)
         symtab_remove_unreachable_nodes (true, dump_file);
       /* Restore current_pass.  */
Index: gcc/testsuite/gcc.dg/lto/pr60911_0.c
===================================================================
--- gcc/testsuite/gcc.dg/lto/pr60911_0.c	(revision 0)
+++ gcc/testsuite/gcc.dg/lto/pr60911_0.c	(working copy)
@@ -0,0 +1,21 @@
+// { dg-lto-do run }
+// { dg-lto-options { { -O2 -flto -fipa-pta } } }
+
+int __attribute__ ((__noinline__)) f (unsigned *p, int *x)
+{
+  int y = *p++ & 0xfff;
+  *x++ = y;
+  *x = *p;
+  return y;
+}
+
+int
+main ()
+{
+  unsigned u[2] = { 0x3aad, 0x5ad1 };
+  int x[2] = { 17689, 23456 };
+
+  if (f (u, x) != 0xaad || x[0] != 0xaad || x[1] != 0x5ad1)
+    __builtin_abort ();
+  return 0;
+}

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

end of thread, other threads:[~2014-04-28  8:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24 11:42 [PATCH] Fix PR60911 Richard Biener
2014-04-24 14:37 ` Jan Hubicka
2014-04-25  7:43   ` Richard Biener
2014-04-25 17:20     ` Jan Hubicka
2014-04-28  8:20       ` 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).