OSDN Git Service

2013-01-21 Martin Jambor <mjambor@suse.cz>
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Jan 2013 17:09:22 +0000 (17:09 +0000)
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Jan 2013 17:09:22 +0000 (17:09 +0000)
        PR tree-optimizations/55264
* cgraph.c (cgraph_create_virtual_clone): Mark clones as non-virtual.
* cgraph.h (cgraph_only_called_directly_p): Return false for virtual
functions.
* ipa-inline.c (cgraph_clone_inlined_nodes): Do reuse nodes of any
virtual function.
* ipa.c (cgraph_remove_unreachable_nodes): Never return true for
virtual methods before inlining is over.

testsuite/
* g++.dg/ipa/pr55264.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@195340 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/ipa-inline.c
gcc/ipa.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/pr55264.C [new file with mode: 0644]

index 370363b..6d73511 100644 (file)
@@ -1,3 +1,17 @@
+2013-01-21  Martin Jambor  <mjambor@suse.cz>
+
+       Backport from mainline
+       2013-01-17  Martin Jambor  <mjambor@suse.cz>
+
+        PR tree-optimizations/55264
+       * cgraph.c (cgraph_create_virtual_clone): Mark clones as non-virtual.
+       * cgraph.h (cgraph_only_called_directly_p): Return false for virtual
+       functions.
+       * ipa-inline.c (cgraph_clone_inlined_nodes): Do reuse nodes of any
+       virtual function.
+       * ipa.c (cgraph_remove_unreachable_nodes): Never return true for
+       virtual methods before inlining is over.
+
 2013-01-14  Matthias Klose  <doko@ubuntu.com>
 
        * doc/invoke.texi: Document -print-multiarch.
index d62674a..201e77d 100644 (file)
@@ -2342,6 +2342,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
   TREE_PUBLIC (new_node->decl) = 0;
   DECL_COMDAT (new_node->decl) = 0;
   DECL_WEAK (new_node->decl) = 0;
+  DECL_VIRTUAL_P (new_node->decl) = 0;
   new_node->clone.tree_map = tree_map;
   new_node->clone.args_to_skip = args_to_skip;
   FOR_EACH_VEC_ELT (ipa_replace_map_p, tree_map, i, map)
index c83b4d3..bad1bb9 100644 (file)
@@ -912,6 +912,7 @@ cgraph_only_called_directly_p (struct cgraph_node *node)
   gcc_assert (!node->global.inlined_to);
   return (!node->needed && !node->address_taken
          && !node->reachable_from_other_partition
+         && !DECL_VIRTUAL_P (node->decl)
          && !DECL_STATIC_CONSTRUCTOR (node->decl)
          && !DECL_STATIC_DESTRUCTOR (node->decl)
          && !node->local.externally_visible);
index 62e1610..3fc796a 100644 (file)
@@ -243,8 +243,7 @@ cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate,
             those only after all devirtualizable virtual calls are processed.
             Lacking may edges in callgraph we just preserve them post
             inlining.  */
-         && (!DECL_VIRTUAL_P (e->callee->decl)
-             || (!DECL_COMDAT (e->callee->decl) && !DECL_EXTERNAL (e->callee->decl)))
+         && !DECL_VIRTUAL_P (e->callee->decl)
          /* Don't reuse if more than one function shares a comdat group.
             If the other function(s) are needed, we need to emit even
             this function out of line.  */
index 4955408..ade8706 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -235,9 +235,7 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
     if (node->analyzed && !node->global.inlined_to
        && (!cgraph_can_remove_if_no_direct_calls_and_refs_p (node)
            /* Keep around virtual functions for possible devirtualization.  */
-           || (before_inlining_p
-               && DECL_VIRTUAL_P (node->decl)
-               && (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl)))
+           || (before_inlining_p && DECL_VIRTUAL_P (node->decl))
            /* Also external functions with address taken are better to stay
               for indirect inlining.  */
            || (before_inlining_p
index 81664c6..457de3f 100644 (file)
@@ -1,3 +1,11 @@
+2013-01-21  Martin Jambor  <mjambor@suse.cz>
+
+       Backport from mainline
+       2013-01-17  Martin Jambor  <mjambor@suse.cz>
+
+        PR tree-optimizations/55264
+       * g++.dg/ipa/pr55264.C: New test.
+
 2013-01-14  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/55072
diff --git a/gcc/testsuite/g++.dg/ipa/pr55264.C b/gcc/testsuite/g++.dg/ipa/pr55264.C
new file mode 100644 (file)
index 0000000..cf54d6a
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining -fno-weak"  } */
+
+struct S
+{
+  S();
+  virtual inline void foo ()
+  {
+    foo();
+  }
+};
+
+void
+B ()
+{
+  S().foo ();
+}