Starting from the revision I see the following ICE: $ cat 1.ii class BDS_Mesh { virtual ~BDS_Mesh(); }; BDS_Mesh::~BDS_Mesh() {} $ cat 2.ii class BDS_Mesh { public: virtual ~BDS_Mesh(); }; void fn1() { BDS_Mesh *m = new BDS_Mesh; for (;;) delete m; } $ g++ 1.ii -c -O0 -flto -shared -fPIC && g++ 2.ii -c -O2 -flto -shared -fPIC && g++ 1.o 2.o -shared during GIMPLE pass: fre 2.ii: In function ‘fn1’: 2.ii:5:6: internal compiler error: Segmentation fault 5 | void fn1() { | ^ 0xc84b5f crash_signal /home/marxin/Programming/gcc/gcc/toplev.c:326 0x7f130c4e1e4f ??? /usr/src/debug/glibc-2.29-7.3.x86_64/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0xa6fcdd tree_check(tree_node*, char const*, int, char const*, tree_code) /home/marxin/Programming/gcc/gcc/tree.h:3256 0xa6fcdd subbinfo_with_vtable_at_offset(tree_node*, unsigned long, tree_node*) /home/marxin/Programming/gcc/gcc/ipa-devirt.c:2760 0xa920b6 extr_type_from_vtbl_ptr_store /home/marxin/Programming/gcc/gcc/ipa-polymorphic-call.c:1321 0xa920b6 check_stmt_for_type_change /home/marxin/Programming/gcc/gcc/ipa-polymorphic-call.c:1522 0xd85048 walk_aliased_vdefs_1 /home/marxin/Programming/gcc/gcc/tree-ssa-alias.c:3466 0xd850ee walk_aliased_vdefs_1 /home/marxin/Programming/gcc/gcc/tree-ssa-alias.c:3449 0xd8519f walk_aliased_vdefs(ao_ref*, tree_node*, bool (*)(ao_ref*, tree_node*, void*), void*, bitmap_head**, bool*, unsigned int) /home/marxin/Programming/gcc/gcc/tree-ssa-alias.c:3488 0xa91672 ipa_polymorphic_call_context::get_dynamic_type(tree_node*, tree_node*, tree_node*, gimple*, unsigned int*) /home/marxin/Programming/gcc/gcc/ipa-polymorphic-call.c:1736 0xe3b4a2 eliminate_dom_walker::eliminate_stmt(basic_block_def*, gimple_stmt_iterator*) /home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:5739 0xe3c61d eliminate_dom_walker::before_dom_children(basic_block_def*) /home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:5898 0xe3c61d eliminate_dom_walker::before_dom_children(basic_block_def*) /home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:5831 0x14b3367 dom_walker::walk(basic_block_def*) /home/marxin/Programming/gcc/gcc/domwalk.c:309 0xe350bb eliminate_with_rpo_vn(bitmap_head*) /home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:6076 0xe44708 do_rpo_vn /home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:7221 0xe452f8 execute /home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:7303 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. make: *** [/tmp/cc5CSQUP.mk:2: /tmp/cc9Jtc0u.ltrans0.ltrans.o] Error 1 lto-wrapper: fatal error: make returned 2 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status
I will have a look.
TYPE_BINFO (DECL_CONTEXT (vtable)) is NULL. DECL_CONTEXT is BDS_Mesh here, from the -O0 compile where it is cleared here: static void free_lang_data_in_type (tree type, class free_lang_data_d *fld) { ... if (TYPE_BINFO (type)) { free_lang_data_in_binfo (TYPE_BINFO (type)); /* We need to preserve link to bases and virtual table for all polymorphic types to make devirtualization machinery working. */ if (!BINFO_VTABLE (TYPE_BINFO (type)) || !flag_devirtualize) TYPE_BINFO (type) = NULL; so I guess that flag_devirtualize is to blame since it may differ between CUs and type merging may chose the instance from a !flag_devirtualize one. A fix could be as simple as removing the !flag_devirtualize case. Honza?
> > so I guess that flag_devirtualize is to blame since it may differ between > CUs and type merging may chose the instance from a !flag_devirtualize one. > A fix could be as simple as removing the !flag_devirtualize case. Yes, the removal of '!flag_devirtualize' looks logical to me.
*** Bug 91387 has been marked as a duplicate of this bug. ***
Author: rguenth Date: Mon Aug 12 11:02:21 2019 New Revision: 274310 URL: https://gcc.gnu.org/viewcvs?rev=274310&root=gcc&view=rev Log: 2019-08-12 Richard Biener <rguenther@suse.de> PR lto/91375 * tree.c (free_lang_data_in_type): Do not free TYPE_BINFO dependent on flag_devirtualize. Modified: trunk/gcc/ChangeLog trunk/gcc/tree.c
Author: rguenth Date: Mon Aug 12 12:59:08 2019 New Revision: 274311 URL: https://gcc.gnu.org/viewcvs?rev=274311&root=gcc&view=rev Log: 2019-08-12 Richard Biener <rguenther@suse.de> Backport from mainline 2019-08-12 Richard Biener <rguenther@suse.de> PR lto/91375 * tree.c (free_lang_data_in_type): Do not free TYPE_BINFO dependent on flag_devirtualize. 2019-08-12 Richard Biener <rguenther@suse.de> PR driver/91130 * lto-wrapper.c (get_options_from_collect_gcc_options): Remove lang_mask option, always use CL_DRIVER. (find_and_merge_options): Adjust. (run_gcc): Likewise. 2019-08-07 Richard Earnshaw <rearnsha@arm.com> PR driver/91130 * lto-wrapper.c (find_and_merge_options): Use CL_DRIVER when processing COLLECT_GCC_OPTIONS. (run_gcc): Likewise. Modified: branches/gcc-9-branch/gcc/ChangeLog branches/gcc-9-branch/gcc/lto-wrapper.c branches/gcc-9-branch/gcc/tree.c
Author: rguenth Date: Fri Aug 30 11:39:19 2019 New Revision: 275100 URL: https://gcc.gnu.org/viewcvs?rev=275100&root=gcc&view=rev Log: 2019-08-30 Richard Biener <rguenther@suse.de> Backport from mainline 2019-08-12 Richard Biener <rguenther@suse.de> PR lto/91375 * tree.c (free_lang_data_in_type): Do not free TYPE_BINFO dependent on flag_devirtualize. 2019-07-31 Richard Biener <rguenther@suse.de> PR tree-optimization/91293 * tree-vect-slp.c (vect_build_slp_tree_2): Do not swap operands of reduction stmts. * gcc.dg/vect/pr91293-1.c: New testcase. * gcc.dg/vect/pr91293-2.c: Likewise. * gcc.dg/vect/pr91293-3.c: Likewise. 2019-07-31 Richard Biener <rguenther@suse.de> PR tree-optimization/91280 * tree-ssa-structalias.c (get_constraint_for_component_ref): Decompose MEM_REF manually for offset handling. * g++.dg/torture/pr91280.C: New testcase. 2019-07-19 Richard Biener <rguenther@suse.de> PR tree-optimization/91200 * tree-ssa-phiopt.c (cond_store_replacement): Check we have no PHI nodes in middle-bb. * gcc.dg/torture/pr91200.c: New testcase. 2019-07-15 Richard Biener <rguenther@suse.de> PR middle-end/91162 * tree-cfg.c (move_block_to_fn): When releasing a virtual PHI node make sure to replace all uses with something valid. * gcc.dg/autopar/pr91162.c: New testcase. 2019-07-11 Richard Biener <rguenther@suse.de> PR middle-end/91131 * gimplify.c (gimplify_compound_literal_expr): Force a temporary when the object is volatile and we have not cleared it even though there are no nonzero elements. * gcc.target/i386/pr91131.c: New testcase. 2019-07-10 Richard Biener <rguenther@suse.de> PR tree-optimization/91126 * tree-ssa-sccvn.c (vn_reference_lookup_3): Adjust native encoding offset for BYTES_BIG_ENDIAN. * gcc.dg/torture/pr91126.c: New testcase. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/torture/pr91280.C branches/gcc-8-branch/gcc/testsuite/gcc.dg/autopar/pr91162.c branches/gcc-8-branch/gcc/testsuite/gcc.dg/torture/pr91126.c branches/gcc-8-branch/gcc/testsuite/gcc.dg/torture/pr91200.c branches/gcc-8-branch/gcc/testsuite/gcc.dg/vect/pr91293-1.c branches/gcc-8-branch/gcc/testsuite/gcc.dg/vect/pr91293-2.c branches/gcc-8-branch/gcc/testsuite/gcc.dg/vect/pr91293-3.c branches/gcc-8-branch/gcc/testsuite/gcc.target/i386/pr91131.c Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/gimplify.c branches/gcc-8-branch/gcc/testsuite/ChangeLog branches/gcc-8-branch/gcc/tree-cfg.c branches/gcc-8-branch/gcc/tree-ssa-phiopt.c branches/gcc-8-branch/gcc/tree-ssa-sccvn.c branches/gcc-8-branch/gcc/tree-ssa-structalias.c branches/gcc-8-branch/gcc/tree-vect-slp.c branches/gcc-8-branch/gcc/tree.c
Fixed.