re PR ipa/60911 (wrong code with -O2 -flto -fipa-pta)
authorRichard Biener <rguenther@suse.de>
Fri, 25 Apr 2014 07:44:40 +0000 (07:44 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 25 Apr 2014 07:44:40 +0000 (07:44 +0000)
2014-04-25  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.

From-SVN: r209779

gcc/ChangeLog
gcc/passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/pr60911_0.c [new file with mode: 0644]

index 3eb5c43f5a5befa3d6cb723fd86b8e9758c9c981..ec3c2e2f66b0ae0e08f476db8c9abec7b9baac81 100644 (file)
@@ -1,3 +1,10 @@
+2014-04-25  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.
+
 2014-04-24  Cong Hou  <congh@google.com>
 
        PR tree-optimization/60896
index 2be7856f29b8dfd7f518d8f21ec6baadfb74af95..fb60fc8fdd676a63ef0f3810b5308488b4a10230 100644 (file)
@@ -2039,20 +2039,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
@@ -2124,8 +2110,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 01912624d51a49862c66a0db0129432026834442..6d0fe01b4144b81df0a1dc6d9ab62ccd8367849e 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-25  Richard Biener  <rguenther@suse.de>
+
+       PR ipa/60911
+       * gcc.dg/lto/pr60911_0.c: New testcase.
+
 2014-04-24  Cong Hou  <congh@google.com>
 
        PR tree-optimization/60896
diff --git a/gcc/testsuite/gcc.dg/lto/pr60911_0.c b/gcc/testsuite/gcc.dg/lto/pr60911_0.c
new file mode 100644 (file)
index 0000000..e4820a2
--- /dev/null
@@ -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;
+}