https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104172
Bug ID: 104172 Summary: [9/10/11/12 Regression] ppc64le mangling ICE with -flto -ffat-lto-objects Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- // { dg-do compile { target { powerpc*-*-* && lp64 && le } } } // { dg-options "-O2 -flto=auto -ffat-lto-objects -mabi=ieeelongdouble" } struct A { A(int); }; struct B { float b; }; struct C : B { C(); }; C::C() { A(b * 25.4L); } ICEs PagePrinter.C: In member function 'C::C()': PagePrinter.C:7:1: internal compiler error: tree check: expected class 'type', have 'declaration' (translation_unit_decl) in base_ctor_omit_inherited_parms, at cp/method.c:568 7 | C::C() { A(b * 25.4L); } | ^ 0x101fbd8b tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../gcc/tree.c:8752 0x104073bf tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../gcc/tree.h:3564 0x104073bf base_ctor_omit_inherited_parms(tree_node*) ../../gcc/cp/method.c:568 0x104073bf base_ctor_omit_inherited_parms(tree_node*) ../../gcc/cp/method.c:560 0x103eda0b write_method_parms ../../gcc/cp/mangle.c:2798 0x103edd73 write_bare_function_type ../../gcc/cp/mangle.c:2758 0x103edecf write_encoding ../../gcc/cp/mangle.c:832 0x103eec7f mangle_decl_string ../../gcc/cp/mangle.c:4034 0x103ef003 get_mangled_id ../../gcc/cp/mangle.c:4055 0x103ef003 mangle_decl(tree_node*) ../../gcc/cp/mangle.c:4093 0x1142297f rs6000_globalize_decl_name ../../gcc/config/rs6000/rs6000.c:28190 0x113d8c43 globalize_decl ../../gcc/varasm.c:6146 0x113e112b assemble_start_function(tree_node*, char const*) ../../gcc/varasm.c:1965 0x10a01a8f rest_of_handle_final ../../gcc/final.c:4281 0x10a01a8f execute ../../gcc/final.c:4363 (for GCC configured to default to --with-long-double-format=ieee that is a pretty serious regression breaking lots of builds). The bug is in: /* Create an alias for a mangled name where we have changed the mangling (in GCC 8.1, we used U10__float128, and now we use u9__ieee128). This is called via the target hook TARGET_ASM_GLOBALIZE_DECL_NAME. */ #if TARGET_ELF && RS6000_WEAK static void rs6000_globalize_decl_name (FILE * stream, tree decl) { const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0); targetm.asm_out.globalize_label (stream, name); if (rs6000_passes_ieee128 && name[0] == '_' && name[1] == 'Z') { tree save_asm_name = DECL_ASSEMBLER_NAME (decl); const char *old_name; ieee128_mangling_gcc_8_1 = true; lang_hooks.set_decl_assembler_name (decl); old_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); SET_DECL_ASSEMBLER_NAME (decl, save_asm_name); ieee128_mangling_gcc_8_1 = false; if (strcmp (name, old_name) != 0) { fprintf (stream, "\t.weak %s\n", old_name); fprintf (stream, "\t.set %s,%s\n", old_name, name); } } } #endif This is just wrong, mangling is only possible before free_lang_data, not after that, everything should be mangled by then. So, IMHO the backend should note that during mangling that it emitted some u9__ieee128 (when rs6000_mangle_type returns it) and through some hook should cooperate with the C++ FE to create a mangling alias like the FE creates mangling aliases for -fabi-version*.