> 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 multiple optimization passes add speculative edges to the same
indirect call, we may attempt to create duplicate speculative edges
to the same target. This can happen when AutoFDO and IPA-devirt
both analyze the same call site.
This patch adds a check in make_speculative() to detect and skip
duplicate targets by iterating through existing speculative edges for
the same call statement and comparing targets using direct pointer
equality, declaration comparison, and semantic equivalence.
gcc/ChangeLog:
* cgraph.cc (cgraph_edge::make_speculative): Check for existing
speculative edge to the same target before creating a new one.
Thanks,
Kugan
0001-PATCH-1-2-cgraph-Prevent-duplicate-speculative-targe.patch
Description: 0001-PATCH-1-2-cgraph-Prevent-duplicate-speculative-targe.patch
