[gcc r16-5465] ipa: Rewrite callback_edge_useful_p heuristic.
Josef Melcr
jmelcr@gcc.gnu.org
Fri Nov 21 08:18:56 GMT 2025
https://gcc.gnu.org/g:0343c45a3387ac5e1e365c97e56ea8305ba67016
commit r16-5465-g0343c45a3387ac5e1e365c97e56ea8305ba67016
Author: Josef Melcr <josef.melcr@suse.com>
Date: Thu Nov 20 23:46:38 2025 +0100
ipa: Rewrite callback_edge_useful_p heuristic.
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>
Diff:
---
gcc/attr-callback.cc | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/gcc/attr-callback.cc b/gcc/attr-callback.cc
index ee39ef61a20d..04b5ad0ef119 100644
--- a/gcc/attr-callback.cc
+++ b/gcc/attr-callback.cc
@@ -344,11 +344,19 @@ bool
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
More information about the Gcc-cvs
mailing list