https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124276
Bug ID: 124276
Summary: Error ocurrs within building mysql 8.0.25 with
-fdevirtualize and -fdump-tree-all
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yw987194828 at gmail dot com
Target Milestone: ---
gcc information
gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../configure CFLAGS='-g3 -gdwarf-2 -O0' CXXFLAGS='-g3
-gdwarf-2 -O0' 'CFLAGS_FOR_TARGET=-g3 -gdwarf-2 -O0' 'CXXFLAGS_FOR_TARGET=-g3
-gdwarf-2 -O0' --enable-shared --enable-threads=posix --enable-checking=release
--enable-__cxa_atexit --enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-languages=c,c++,fortran,lto
--enable-initfini-array --enable-gnu-indirect-function --with-gnu-as
--with-gnu-ld --enable-libquadmath --disable-bootstrap --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.1 20260211 (experimental) (GCC)
compile command
cc1plus gcs_xcom_communication_protocol_changer.i -quiet -O1 -fdump-tree-all
-fdevirtualize -fdevirtualize-speculatively -o /tmp/ccNb4SCF.s
error
during GIMPLE pass: fre
dump file: gcs_xcom_communication_protocol_changer.i.044t.fre1
mysql-8.0.25/plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_communication_protocol_changer.cc:
In member function ‘void
Gcs_xcom_communication_protocol_changer::rollback_increment_nr_packets_in_transit(const
Gcs_tagged_lock::Tag&)’:
mysql-8.0.25/plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_communication_protocol_changer.cc:337:1:
internal compiler error: in dump_possible_polymorphic_call_targets, at
ipa-devirt.cc:3470
337 | }
| ^
0x370b176 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:787
0x3715002 fancy_abort(char const*, int, char const*)
../../gcc/diagnostics/context.cc:1812
0x17a9c89 dump_possible_polymorphic_call_targets(_IO_FILE*, tree_node*, long,
ipa_polymorphic_call_context const&, bool)
../../gcc/ipa-devirt.cc:3470
0x1dde0d9 eliminate_dom_walker::eliminate_stmt(basic_block_def*,
gimple_stmt_iterator*)
../../gcc/tree-ssa-sccvn.cc:7583
0x1de1aa4 process_bb
../../gcc/tree-ssa-sccvn.cc:8603
0x1de3b58 do_rpo_vn_1
../../gcc/tree-ssa-sccvn.cc:9056
0x1de4467 execute
../../gcc/tree-ssa-sccvn.cc:9218
When building MySQL 8.0.25 with GCC trunk and `enable-checking=release`, an
error related to devirtualization occurs: `gcc_assert (symtab->state <
IPA_SSA || targets.length() <= len)` fails.
When `symtab->state == IPA_SSA`, certain types remain unadded to `odr_types`,
such as MySQL's `Protocol_change_notification` type. During the first
invocation of `possible_polymorphic_call_targets` in
`dump_possible_polymorphic_call_targets`, `odr_types` does not include
`Protocol_change_notification`. The second call to
possible_polymorphic_call_targets adds context.speculative_outer_type
(Protocol_change_notification) to odr_types. This is included in the result of
possible_polymorphic_call_targets, and targets.length()(1) <= len(0) does not
hold.
I'm wondering if `symtab->state == IPA_SSA` indicates that `odr_types` now
contains all types in the program at this stage. If so, this contradicts the
MySQL example. Since I'm unfamiliar with how `odr_types` is constructed, it's
not easy to analyze why `Protocol_change_notification` isn't included in
`odr_types` when `symtab->state == IPA_SSA`.