]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix ICE in speculative devirtualization
authorJan Hubicka <hubicka@ucw.cz>
Fri, 11 Jul 2025 10:37:24 +0000 (12:37 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 31 Jul 2025 07:43:30 +0000 (09:43 +0200)
commit1b42af2d10bd6ec11ffa25431445cd609384e690
treefe5cddcd63b1d29a9151d777c2c7685dcb8d0845
parente442d6f4964daec3c9dfeb52101d9f80ff363f27
Fix ICE in speculative devirtualization

This patch fixes ICE bilding lto1 with autoprofiledbootstrap and in pr114790.
What happens is that auto-fdo speculatively devirtualizes to a wrong target.
This is due to a bug where it mixes up dwarf names and linkage names of inline
functions I need to fix as well.

Later we clone at WPA time. At ltrans time clone is materialized and call is
turned into a direct call (this optimization is missed by ipa-cp propagation).
At this time we should resolve speculation but we don't.  As a result we get
error from verifier after inlining complaining that there is speculative call
with corresponding direct call lacking speculative flag.

This seems long-lasting problem in cgraph_update_edges_for_call_stmt_node but
I suppose it does not trigger since we usually speculate correctly or notice
the direct call at WPA time already.

Bootstrapped/regtested x86_64-linux.

gcc/ChangeLog:

PR ipa/114790
* cgraph.cc (cgraph_update_edges_for_call_stmt_node): Resolve devirtualization
if call statement was optimized out or turned to direct call.

gcc/testsuite/ChangeLog:

* g++.dg/lto/pr114790_0.C: New test.
* g++.dg/lto/pr114790_1.C: New test.

(cherry picked from commit 52d9c2272f6366cd5b30e9540ce8ef16b482cee5)
gcc/cgraph.cc
gcc/testsuite/g++.dg/lto/pr114790_0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr114790_1.C [new file with mode: 0644]