cgraph.h (cgraph_node): New method expand_all_artificial_thunks.
authorMartin Jambor <mjambor@suse.cz>
Fri, 5 Dec 2014 11:06:26 +0000 (12:06 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Fri, 5 Dec 2014 11:06:26 +0000 (12:06 +0100)
2014-12-05  Martin Jambor  <mjambor@suse.cz>

* cgraph.h (cgraph_node): New method expand_all_artificial_thunks.
(cgraph_edge): New method redirect_callee_duplicating_thunks.
* cgraphclones.c (duplicate_thunk_for_node): Donot expand newly
created thunks.
(redirect_edge_duplicating_thunks): Turned into edge method
redirect_callee_duplicating_thunks.
(cgraph_node::expand_all_artificial_thunks): New method.
(create_clone): Call expand_all_artificial_thunks.
* ipa-cp.c (perhaps_add_new_callers): Call
redirect_callee_duplicating_thunks instead of redirect_callee.
Also call expand_all_artificial_thunks.

From-SVN: r218417

gcc/ChangeLog
gcc/cgraph.h
gcc/cgraphclones.c
gcc/ipa-cp.c

index 9e66e6053c202766cab626f0eb8776dac1ba3abd..c0ee60bf9b3f3394e2c9af55e3a5d5162673e92b 100644 (file)
@@ -1,3 +1,17 @@
+2014-12-05  Martin Jambor  <mjambor@suse.cz>
+
+       * cgraph.h (cgraph_node): New method expand_all_artificial_thunks.
+       (cgraph_edge): New method redirect_callee_duplicating_thunks.
+       * cgraphclones.c (duplicate_thunk_for_node): Donot expand newly
+       created thunks.
+       (redirect_edge_duplicating_thunks): Turned into edge method
+       redirect_callee_duplicating_thunks.
+       (cgraph_node::expand_all_artificial_thunks): New method.
+       (create_clone): Call expand_all_artificial_thunks.
+       * ipa-cp.c (perhaps_add_new_callers): Call
+       redirect_callee_duplicating_thunks instead of redirect_callee.
+       Also call expand_all_artificial_thunks.
+
 2014-12-05  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        PR target/64056
index 04318f58c7a5e74a561073f33f46c705e4aecd31..54ee748941671827dc54f85e955532fc7478d1a3 100644 (file)
@@ -908,6 +908,10 @@ public:
      thunks that are not lowered.  */
   bool expand_thunk (bool output_asm_thunks, bool force_gimple_thunk);
 
+  /*  Call expand_thunk on all callers that are thunks and analyze those
+      nodes that were expanded.  */
+  void expand_all_artificial_thunks ();
+
   /* Assemble thunks and aliases associated to node.  */
   void assemble_thunks_and_aliases (void);
 
@@ -1477,6 +1481,12 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
      call expression.  */
   void redirect_callee (cgraph_node *n);
 
+  /* If the edge does not lead to a thunk, simply redirect it to N.  Otherwise
+     create one or more equivalent thunks for N and redirect E to the first in
+     the chain.  Note that it is then necessary to call
+     n->expand_all_artificial_thunks once all callers are redirected.  */
+  void redirect_callee_duplicating_thunks (cgraph_node *n);
+
   /* Make an indirect edge with an unknown callee an ordinary edge leading to
      CALLEE.  DELTA is an integer constant that is to be added to the this
      pointer (first parameter) to compensate for skipping
index 086dd92ebde2d22dd23749fbca2e594e34e0a980..1bf0477a48cd60fd11b25799f26a4c94022dab5b 100644 (file)
@@ -370,28 +370,47 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
                                                  CGRAPH_FREQ_BASE);
   e->call_stmt_cannot_inline_p = true;
   symtab->call_edge_duplication_hooks (thunk->callees, e);
-  if (new_thunk->expand_thunk (false, false))
-    {
-      new_thunk->thunk.thunk_p = false;
-      new_thunk->analyze ();
-    }
-
   symtab->call_cgraph_duplication_hooks (thunk, new_thunk);
   return new_thunk;
 }
 
 /* If E does not lead to a thunk, simply redirect it to N.  Otherwise create
    one or more equivalent thunks for N and redirect E to the first in the
-   chain.  */
+   chain.  Note that it is then necessary to call
+   n->expand_all_artificial_thunks once all callers are redirected.  */
 
 void
-redirect_edge_duplicating_thunks (cgraph_edge *e, cgraph_node *n)
+cgraph_edge::redirect_callee_duplicating_thunks (cgraph_node *n)
 {
-  cgraph_node *orig_to = e->callee->ultimate_alias_target ();
+  cgraph_node *orig_to = callee->ultimate_alias_target ();
   if (orig_to->thunk.thunk_p)
     n = duplicate_thunk_for_node (orig_to, n);
 
-  e->redirect_callee (n);
+  redirect_callee (n);
+}
+
+/* Call expand_thunk on all callers that are thunks and if analyze those nodes
+   that were expanded.  */
+
+void
+cgraph_node::expand_all_artificial_thunks ()
+{
+  cgraph_edge *e;
+  for (e = callers; e;)
+    if (e->caller->thunk.thunk_p)
+      {
+       cgraph_node *thunk = e->caller;
+
+       e = e->next_caller;
+       if (thunk->expand_thunk (false, false))
+         {
+           thunk->thunk.thunk_p = false;
+           thunk->analyze ();
+         }
+       thunk->expand_all_artificial_thunks ();
+      }
+    else
+      e = e->next_caller;
 }
 
 /* Create node representing clone of N executed COUNT times.  Decrease
@@ -483,8 +502,9 @@ cgraph_node::create_clone (tree decl, gcov_type gcov_count, int freq,
       if (!e->callee
          || DECL_BUILT_IN_CLASS (e->callee->decl) != BUILT_IN_NORMAL
          || DECL_FUNCTION_CODE (e->callee->decl) != BUILT_IN_UNREACHABLE)
-        redirect_edge_duplicating_thunks (e, new_node);
+        e->redirect_callee_duplicating_thunks (new_node);
     }
+  new_node->expand_all_artificial_thunks ();
 
   for (e = callees;e; e=e->next_callee)
     e->clone (new_node, e->call_stmt, e->lto_stmt_uid, count_scale,
index 3baa11586264b32601d9b9913fb7f516ee320263..9b6784b8b5fc6a2be36b9f573ce1fbf8b7fe5a6d 100644 (file)
@@ -3912,7 +3912,8 @@ perhaps_add_new_callers (cgraph_node *node, ipcp_value<valtype> *val)
                         xstrdup (val->spec_node->name ()),
                         val->spec_node->order);
 
-             cs->redirect_callee (val->spec_node);
+             cs->redirect_callee_duplicating_thunks (val->spec_node);
+             val->spec_node->expand_all_artificial_thunks ();
              redirected_sum += cs->count;
            }
          cs = get_next_cgraph_edge_clone (cs);