]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa: Delete callback edges when redirecting to unreachable.
authorJosef Melcr <jmelcr02@gmail.com>
Sat, 18 Oct 2025 10:47:17 +0000 (12:47 +0200)
committerJosef Melcr <jmelcr02@gmail.com>
Mon, 20 Oct 2025 22:11:26 +0000 (00:11 +0200)
When a callback-carrying edge is redirected to __builtin_unreachable,
the associated callbacks will never get called, so the corresponding
callback edges must be deleted, as they no longer reflect the reality.

The line in analyze_function_body is an obvious typo I discovered during
debugging, so I decided to bundle it in.

gcc/ChangeLog:

* ipa-fnsummary.cc (redirect_to_unreachable): Purge callback
edges when redirecting the carrying edge.
(analyze_function_body): Fix typo.

Signed-off-by: Josef Melcr <jmelcr02@gmail.com>
gcc/ipa-fnsummary.cc

index e7b81d83fe1aaa0b76e4b46796781eae17eaa2a5..bf98a449584422393d290354bcc2a5d8464e11b8 100644 (file)
@@ -271,6 +271,8 @@ redirect_to_unreachable (struct cgraph_edge *e)
   es->call_stmt_time = 0;
   if (callee)
     callee->remove_symbol_and_inline_clones ();
+  if (e->has_callback)
+    e->purge_callback_edges ();
   return e;
 }
 
@@ -3119,8 +3121,7 @@ analyze_function_body (struct cgraph_node *node, bool early)
                  for (cbe = edge->first_callback_edge (); cbe;
                       cbe = cbe->next_callback_edge ())
                    {
-                     ipa_call_summary *es2 = ipa_call_summaries->get (cbe);
-                     es2 = ipa_call_summaries->get_create (cbe);
+                     ipa_call_summary *es2 = ipa_call_summaries->get_create (cbe);
                      ipa_call_summaries->duplicate (edge, cbe, es, es2);
                      /* Unlike speculative edges, callback edges have no real
                         size or time; the call doesn't exist.  Reflect that in