OSDN Git Service

PR c++/25010
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Dec 2005 04:16:32 +0000 (04:16 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Dec 2005 04:16:32 +0000 (04:16 +0000)
* ipa-inline.c (cgraph_clone_inlined_nodes): Do not assume that
DECL_EXTERNAL functions have no bodies.  Tidy.
PR c++/25010
* g++.dg/opt/inline10.C: New test.

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

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

index c16e947..ceadb23 100644 (file)
@@ -115,24 +115,26 @@ cgraph_estimate_size_after_inlining (int times, struct cgraph_node *to,
 void
 cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate, bool update_original)
 {
-  struct cgraph_node *n;
-
-  /* We may eliminate the need for out-of-line copy to be output.  In that
-     case just go ahead and re-use it.  */
-  if (!e->callee->callers->next_caller
-      && (!e->callee->needed || DECL_EXTERNAL (e->callee->decl))
-      && duplicate
-      && flag_unit_at_a_time)
+  if (duplicate)
     {
-      gcc_assert (!e->callee->global.inlined_to);
-      if (!DECL_EXTERNAL (e->callee->decl))
-        overall_insns -= e->callee->global.insns, nfunctions_inlined++;
-      duplicate = 0;
-    }
-   else if (duplicate)
-    {
-      n = cgraph_clone_node (e->callee, e->count, e->loop_nest, update_original);
-      cgraph_redirect_edge_callee (e, n);
+      /* We may eliminate the need for out-of-line copy to be output.
+        In that case just go ahead and re-use it.  */
+      if (!e->callee->callers->next_caller
+         && !e->callee->needed
+         && flag_unit_at_a_time)
+       {
+         gcc_assert (!e->callee->global.inlined_to);
+         if (DECL_SAVED_TREE (e->callee->decl))
+           overall_insns -= e->callee->global.insns, nfunctions_inlined++;
+         duplicate = false;
+       }
+      else
+       {
+         struct cgraph_node *n;
+         n = cgraph_clone_node (e->callee, e->count, e->loop_nest, 
+                                update_original);
+         cgraph_redirect_edge_callee (e, n);
+       }
     }
 
   if (e->caller->global.inlined_to)
index 5edcf7d..28b6eda 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-10  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/25010
+       * g++.dg/opt/inline10.C: New test.
+
 2005-12-11  Steven G. Kargl  <kargls@comcast.net>
 
        * gfortran.dg/g77/19981216-0.f: Fix for fortran/25068.
diff --git a/gcc/testsuite/g++.dg/opt/inline10.C b/gcc/testsuite/g++.dg/opt/inline10.C
new file mode 100644 (file)
index 0000000..086a481
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/25010
+// { dg-options "-O2" }
+
+#pragma interface
+
+struct T
+{
+  T *p;
+
+  void baz ()
+  {
+    p->baz ();
+  }
+};
+
+void foo (T *p)
+{
+  p->baz ();
+}
+