https://gcc.gnu.org/g:5527996c4431821c10be39e89b8b2caaa93e5efe
commit r16-5453-g5527996c4431821c10be39e89b8b2caaa93e5efe Author: Josef Melcr <[email protected]> Date: Thu Nov 20 13:32:45 2025 +0100 ipa: Add early return when the hashed edge is a callback-carrying edge. The inclusion of this early return statement has been discussed before, it was ultimately left out of the original patch, but it turns out to be necessary. When a callback edge is being created, it is first created by symbol_table::create_edge, which is where it is added to the call site hash. However, its callback flag is not set at that point, so the early return for callback edges doesn't affect it. This causes the wrong edge to be hashed, ultimately leading to segfaults and ICEs. This happens many times in the testsuite, the one I noticed first was libgomp.fortran/simd7.f90. gcc/ChangeLog: PR ipa/122358 * cgraph.cc (cgraph_add_edge_to_call_site_hash): Add an early return when the hashed edge is a callback-carrying edge. Signed-off-by: Josef Melcr <[email protected]> Diff: --- gcc/cgraph.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index ab09376a1a0d..3c21e1749430 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -885,9 +885,10 @@ cgraph_add_edge_to_call_site_hash (cgraph_edge *e) gcc_assert (edge->speculative || edge->has_callback); if (edge->has_callback) /* If the slot is already occupied, then the hashed edge is the - callback-carrying edge, which is desired behavior, so we can safely - return. */ - gcc_checking_assert (edge == e); + callback-carrying edge, which is desired behavior. In some cases, + the callback flag of E is not set yet and so the early exit above is + not taken. */ + return; if (e->callee && (!e->prev_callee || !e->prev_callee->speculative || e->prev_callee->call_stmt != e->call_stmt))
