From: Josef Melcr Date: Sat, 18 Oct 2025 10:47:17 +0000 (+0200) Subject: ipa: Delete callback edges when redirecting to unreachable. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9966cbfafb0266e473ab2178b394455846221c91;p=thirdparty%2Fgcc.git ipa: Delete callback edges when redirecting to unreachable. 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 --- diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc index e7b81d83fe1..bf98a449584 100644 --- a/gcc/ipa-fnsummary.cc +++ b/gcc/ipa-fnsummary.cc @@ -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