> On 9 Jan 2026, at 5:48 pm, Kugan Vivekanandarajah <[email protected]> 
> wrote:
> 
> The issue is shows up in  AutoFDO with:
> 
>    • Multiple speculative calls within a single function.
>    • Complex interactions between the AutoFDO early-inliner, 
> devirtualization, and indirect call transformation.
>    • The ICE triggers when these calls are processed across different IPA 
> passes that inadvertently disrupt the cgraph_edge linked-list adjacency.
> 
> See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123496
> 
> I have two patches that ensures the call-graph and call_site_hash invariants 
> are maintained during edge creation/redirection.
> 
> First patch measure that we don't create the same  speculative edges are not 
> adding from different optimisations
> Send patch measure that the order is maintained.
> 
> Bootstrapped and regression tested with now new regressions on 
> aarch64-linux-gnu with no new regressions.
> 
> Is this OK?
> 

When creating speculative edges, ensure they remain adjacent in the callees
list to satisfy verification requirements. The create_edge() function always
inserts new edges at the head of the list, which can break adjacency when
multiple speculative edges exist for the same call statement.

gcc/ChangeLog:

        * cgraph.cc (cgraph_edge::make_speculative): Find the last existing
        speculative edge for the same call_stmt and insert the new edge
        adjacent to it, maintaining the verification invariant.


Thanks,
Kugan

Attachment: 0002-PATCH-2-2-cgraph-Maintain-speculative-edge-adjacency.patch
Description: 0002-PATCH-2-2-cgraph-Maintain-speculative-edge-adjacency.patch

Reply via email to