]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/45621
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Oct 2010 01:20:55 +0000 (01:20 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Oct 2010 01:20:55 +0000 (01:20 +0000)
* g++.dg/lto/pr45621.h : New.
* g++.dg/lto/pr45621_0.C: New.
* g++.dg/lto/pr45621_1.C: New.
* cgraph.c (cgraph_update_edges_for_call_stmt_node): When new call is
redirected to clone, be happy.
* cgraph.h (cgraph node): Enable former_clone_of unconditinally.
* cgraphunit.c (verify_cgraph_node, cgraph_materialize_clone): Handle
former_clone_of unconditinally.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165492 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/cgraphunit.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr45621.h [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr45621_0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr45621_1.C [new file with mode: 0644]

index 262a377d108182ad15a263d79b0bb5d4ec93376c..5c0d576f402972c7f3e06f59616c13081851373b 100644 (file)
@@ -1,3 +1,12 @@
+2010-10-14  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/45621
+       * cgraph.c (cgraph_update_edges_for_call_stmt_node): When new call is
+       redirected to clone, be happy.
+       * cgraph.h (cgraph node): Enable former_clone_of unconditinally.
+       * cgraphunit.c (verify_cgraph_node, cgraph_materialize_clone): Handle
+       former_clone_of unconditinally.
+       
 2010-10-14  Iain Sandoe  <iains@gcc.gnu.org>
 
        merge from FSF apple 'trunk' branch. 
index 7293b6dee03ae6f882859ca9c19a6bf1c7dc120a..465e9afbf79b3471e1b04cf6258abc7e4895fc26 100644 (file)
@@ -1241,9 +1241,18 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node,
        {
          /* See if the edge is already there and has the correct callee.  It
             might be so because of indirect inlining has already updated
-            it.  */
-         if (new_call && e->callee && e->callee->decl == new_call)
-           return;
+            it.  We also might've cloned and redirected the edge.  */
+         if (new_call && e->callee)
+           {
+             struct cgraph_node *callee = e->callee;
+             while (callee)
+               {
+                 if (callee->decl == new_call
+                     || callee->former_clone_of == new_call)
+                   return;
+                 callee = callee->clone_of;
+               }
+           }
 
          /* Otherwise remove edge and create new one; we can't simply redirect
             since function has changed, so inline plan and other information
index 330c88396361bca49ba52dc3054f8518ac92f65a..d7ca67c692f6283f874ce42bdb8940fb3271e257 100644 (file)
@@ -227,11 +227,8 @@ struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
   /* For functions with many calls sites it holds map from call expression
      to the edge to speed up cgraph_edge function.  */
   htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
-#ifdef ENABLE_CHECKING
-  /* Declaration node used to be clone of.  Used for checking only. 
-     We must skip it or we get references from release checking GGC files. */
-  tree GTY ((skip)) former_clone_of;
-#endif
+  /* Declaration node used to be clone of. */
+  tree former_clone_of;
 
   PTR GTY ((skip)) aux;
 
index 95b3007403755c1998a258c73fa1dc92fb7ee9f1..7d4349a8b6dbe43e75a2a7184c67452b3cc486f7 100644 (file)
@@ -656,7 +656,6 @@ verify_cgraph_node (struct cgraph_node *node)
                                debug_tree (e->callee->decl);
                                error_found = true;
                              }
-#ifdef ENABLE_CHECKING
                            else if (!e->callee->global.inlined_to
                                     && decl
                                     && cgraph_get_node (decl)
@@ -671,7 +670,6 @@ verify_cgraph_node (struct cgraph_node *node)
                                debug_tree (decl);
                                error_found = true;
                              }
-#endif
                          }
                        else if (decl)
                          {
@@ -2079,11 +2077,9 @@ static void
 cgraph_materialize_clone (struct cgraph_node *node)
 {
   bitmap_obstack_initialize (NULL);
-#ifdef ENABLE_CHECKING
   node->former_clone_of = node->clone_of->decl;
   if (node->clone_of->former_clone_of)
     node->former_clone_of = node->clone_of->former_clone_of;
-#endif
   /* Copy the OLD_VERSION_NODE function tree to the new version.  */
   tree_function_versioning (node->clone_of->decl, node->decl,
                            node->clone.tree_map, true,
index f722e3747dc588eb9335a6b648e522a8044e3223..6f8e1fdf9da94839f3704ce15dc18036301a8b08 100644 (file)
@@ -1,3 +1,10 @@
+2010-10-14  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/45621
+       * g++.dg/lto/pr45621.h : New.
+       * g++.dg/lto/pr45621_0.C: New.
+       * g++.dg/lto/pr45621_1.C: New.
+
 2010-10-14  Iain Sandoe  <iains@gcc.gnu.org>
 
        * objc.dg/property: New.
diff --git a/gcc/testsuite/g++.dg/lto/pr45621.h b/gcc/testsuite/g++.dg/lto/pr45621.h
new file mode 100644 (file)
index 0000000..81a7642
--- /dev/null
@@ -0,0 +1,8 @@
+struct S
+{
+  void m ();
+  virtual void v1 ();
+  virtual void v2 ();
+};
+
+extern S s;
diff --git a/gcc/testsuite/g++.dg/lto/pr45621_0.C b/gcc/testsuite/g++.dg/lto/pr45621_0.C
new file mode 100644 (file)
index 0000000..746079c
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-lto-do assemble }
+// { dg-extra-ld-options "-O2 -fipa-cp-clone -flto -nostdlib -r" }
+#include "pr45621.h"
+
+void
+foo ()
+{
+  s.v1 ();
+  s.m ();
+}
diff --git a/gcc/testsuite/g++.dg/lto/pr45621_1.C b/gcc/testsuite/g++.dg/lto/pr45621_1.C
new file mode 100644 (file)
index 0000000..2ada6a8
--- /dev/null
@@ -0,0 +1,13 @@
+#include "pr45621.h"
+
+void
+S::v1 ()
+{
+  v2 ();
+}
+
+void
+S::m ()
+{
+  v1 ();
+}