https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128226

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Josef Melcr <[email protected]>:

https://gcc.gnu.org/g:32402de2bbc891ad204419502a68847127e55941

commit r17-6179-g32402de2bbc891ad204419502a68847127e55941
Author: Josef Melcr <[email protected]>
Date:   Thu Nov 12 17:05:49 2026 +0100

    ipa: Add callback edges without carrying edges to call_site_hash [PR128226]

    This patch fixes the early return in
    cgraph_add_edge_to_call_site_hash for internal callback edges.

    Callback edges are created much later than other callgraph edges.  If
    the function doesn't have its call_site_hash yet, the creation of
    callback edges can bring it over the threshold and trigger the
    call_site_hash's construction.  However, callback edges created prior to
    crossing the threshold (i.e. callback edges constructed in the first 100
    edges) won't be added to the call_site_hash due to the early return.

    This is actually the desired behavior for regular callback edges, as we
    want to hash their carrying edges instead.  The trouble arises for
    the recently added internal callback edges, as they don't have a
    carrying edge, leaving the slot empty.  In their case, the callback
    edge is actually the correct one to hash.  This can lead to segfaults
    when fetching the edge after call_site_hash's construction, as is the
    case for PR128226.

    This patch fixes the early return to only apply to callback edges with
    carrying edges.

    The original testcase is long, complicated and doesn't demonstrate the
    problem well, so I've created this one instead.

    Assisted-by: Claude Opus 5.5 (testcase)

            PR ipa/128226

    gcc/ChangeLog:

            * cgraph.cc (cgraph_add_edge_to_call_site_hash): Only skip callback
            edges with carrying edges.

    gcc/testsuite/ChangeLog:

            * g++.dg/ipa/pr128226.C: New test.

    Signed-off-by: Josef Melcr <[email protected]>

Reply via email to