This function is used to determine whether a callback edge should be
kept or not. It was supposed to capture the idea that a callback edge
has been redirected at some point, however, it only considered
redirecting to some clone. However, an edge may not always be
redirected to a clone. For example, common function bodies produced by
icf are not clones. This version of this function should cover all
cases, at least for the time being.
gcc/ChangeLog:
PR ipa/122768
* attr-callback.cc (callback_edge_useful_p): Rewrite the
heuristic, now consider clones as well as icf bodies.
Signed-off-by: Josef Melcr <josef.melcr@suse.com>
callback_edge_useful_p (cgraph_edge *e)
{
gcc_checking_assert (e->callback);
- /* If the edge is not pointing towards a clone, it is no longer useful as its
- entire purpose is to produce clones of callbacks. */
- if (!e->callee->clone_of)
- return false;
- return true;
+ /* If the edge is pointing towards a clone, it is useful. */
+ if (e->callee->clone_of)
+ return true;
+
+ /* If the callee has been produced by icf, the edge is useful, as it will be
+ used to for the redirection. */
+ if (e->callee->icf_merged)
+ return true;
+
+ /* In case some future pass redirects edges, it should be added as a case
+ here. */
+
+ return false;
}
/* Returns the number of arguments the callback function described by ATTR