On Tue, Jan 30, 2024 at 4:58 AM H.J. Lu <hjl.to...@gmail.com> wrote: > > On Tue, Jan 30, 2024 at 4:51 AM Jakub Jelinek <ja...@redhat.com> wrote: > > > > On Mon, Jan 29, 2024 at 06:05:25PM -0800, H.J. Lu wrote: > > > LRA may call forcce_const_mem on this insn in the function > > > > > > (gdb) call debug_tree (func_decl) > > > <function_decl 0x7ffff2770900 __ct_base > > > type <method_type 0x7ffff27511f8 > > > type <void_type 0x7ffff7690f18 void type_6 VOID > > > align:8 warn_if_not_align:0 symtab:0 alias-set -1 > > > canonical-type 0x7ffff7690f18 > > > pointer_to_this <pointer_type 0x7ffff7697000>> > > > QI > > > size <integer_cst 0x7ffff768a2b8 constant 8> > > > unit-size <integer_cst 0x7ffff768a2d0 constant 1> > > > align:8 warn_if_not_align:0 symtab:0 alias-set -1 > > > canonical-type 0x7ffff27512a0 method basetype <record_type > > > 0x7ffff264b0a8 function_summary> > > > arg-types <tree_list 0x7ffff349acd0 value <pointer_type > > > 0x7ffff26887e0> > > > chain <tree_list 0x7ffff349ac58 value <pointer_type > > > 0x7ffff264b2a0> > > > chain <tree_list 0x7ffff48c0b68 > > > purpose <integer_cst 0x7ffff768a510 constant 0> > > > value <boolean_type 0x7ffff7690b28 bool> > > > chain <tree_list 0x7ffff7685d98 value <void_type > > > 0x7ffff7690f18 void>>>>> > > > pointer_to_this <pointer_type 0x7ffff258a888>> > > > addressable asm_written used nothrow public static weak decl_5 QI > > > /export/gnu/import/git/gitlab/x86-gcc/gcc/symbol-summary.h:268:1 > > > align:16 warn_if_not_align:0 context <record_type 0x7ffff264b0a8 > > > function_summary> initial <block 0x7ffff22c82a0> abstract_origin > > > <function_decl 0x7ffff2750700 __ct > > > > result <result_decl 0x7ffff22abd20 D.160175 type <void_type > > > 0x7ffff7690f18 void> > > > ignored VOID > > > /export/gnu/import/git/gitlab/x86-gcc/gcc/symbol-summary.h:269:20 > > > align:8 warn_if_not_align:0 context <function_decl > > > 0x7ffff2770900 __ct_base >> > > > full-name "function_summary<T*>::function_summary(symbol_table*, > > > bool = false) [with T = clone_info]" > > > template-info <template_info 0x7ffff349ade8 > > > template <template_decl 0x7ffff26fbf80 __ct type <method_type > > > 0x7ffff2701540> > > > VOID > > > /export/gnu/import/git/gitlab/x86-gcc/gcc/symbol-summary.h:268:1 > > > align:1 warn_if_not_align:0 context <record_type > > > 0x7ffff27010a8 function_summary> result <function_decl 0x7ffff26fcc00 > > > __ct > > > > parms <tree_list 0x7ffff37bc730 purpose <integer_cst > > > 0x7ffff768a2d0 1> > > > value <tree_vec 0x7ffff304ed00 type <template_decl > > > 0x7ffff2646e00 function_summary> > > > length:1 > > > elt:0 <tree_list 0x7ffff37bc708 value <type_decl > > > 0x7ffff26f5c78 T>>>> > > > full-name "template<class T> > > > function_summary<T*>::function_summary(symbol_table*, bool)"> > > > args <tree_vec 0x7ffff30767a0 length:1 elt:0 <record_type > > > 0x7ffff2987930 clone_info>>> > > > use_template=1 > > > arguments <parm_decl 0x7ffff2773780 this > > > type <pointer_type 0x7ffff2751348 type <record_type > > > 0x7ffff264b0a8 function_summary> > > > readonly sizes-gimplified public unsigned DI > > > size <integer_cst 0x7ffff768a1c8 constant 64> > > > unit-size <integer_cst 0x7ffff768a1e0 constant 8> > > > align:64 warn_if_not_align:0 symtab:0 alias-set -1 > > > canonical-type 0x7ffff2751348> > > > readonly used unsigned read DI > > > /export/gnu/import/git/gitlab/x86-gcc/gcc/symbol-summary.h:269:20 size > > > <integer_cst 0x7ffff768a1c8 64> unit-size <integer_cst 0x7ffff768a1e0 > > > 8> > > > align:64 warn_if_not_align:0 context <function_decl > > > 0x7ffff2770900 __ct_base > abstract_origin <parm_decl 0x7ffff274fa00 > > > this> > > > (reg/f:DI 117 [ this ]) arg-type <pointer_type 0x7ffff2751348> > > > incoming-rtl (reg:DI 5 di [ this ]) > > > chain <parm_decl 0x7ffff2773800 symtab type <pointer_type > > > 0x7ffff264b2a0> > > > used unsigned DI > > > /export/gnu/import/git/gitlab/x86-gcc/gcc/symbol-summary.h:268:56 size > > > <integer_cst 0x7ffff768a1c8 64> unit-size <integer_cst 0x7ffff768a1e0 > > > 8> > > > align:64 warn_if_not_align:0 context <function_decl > > > 0x7ffff2770900 __ct_base > abstract_origin <parm_decl 0x7ffff22c1b80 > > > symtab> > > > (reg/v/f:DI 118 [ symtab ]) arg-type <pointer_type > > > 0x7ffff264b2a0> > > > incoming-rtl (reg:DI 4 si [ symtab ]) chain <parm_decl > > > 0x7ffff2773880 ggc>>> > > > struct-function 0x7ffff22cb228 chain <function_decl 0x7ffff2770800 > > > __ct_comp >> > > > (gdb) > > > > > > in gcc master branch tree: > > > > > > (gdb) call debug_rtx (curr_insn) > > > (insn 14 128 15 2 (set (reg:V2DI 121 [ _21 ]) > > > (vec_concat:V2DI (symbol_ref/i:DI > > > ("_ZN16function_summaryIP10clone_infoE16symtab_insertionEP11cgraph_nodePv") > > > [flags 0x3] <function_decl 0x7ffff2750e00 symtab_insertion>) > > > (symbol_ref/i:DI > > > ("_ZN16function_summaryIP10clone_infoE14symtab_removalEP11cgraph_nodePv") > > > [flags 0x3] <function_decl 0x7ffff2750f00 symtab_removal>))) > > > "/export/gnu/import/git/gitlab/x86-gcc/gcc/symbol-summary.h":36:22 > > > 7521 {vec_concatv2di} > > > (expr_list:REG_DEAD (reg/f:DI 123) > > > (expr_list:REG_DEAD (reg/f:DI 122) > > > (expr_list:REG_EQUIV (vec_concat:V2DI (symbol_ref/i:DI > > > ("_ZN16function_summaryIP10clone_infoE16symtab_insertionEP11cgraph_nodePv") > > > [flags 0x3] <function_decl 0x7ffff2750e00 symtab_insertion>) > > > (symbol_ref/i:DI > > > ("_ZN16function_summaryIP10clone_infoE14symtab_removalEP11cgraph_nodePv") > > > [flags 0x3] <function_decl 0x7ffff2750f00 symtab_removal>)) > > > (nil))))) > > > (gdb) > > > > > > The referenced symbol, > > > function_summary<clone_info*>::symtab_removal(cgraph_node*, void*), > > > and the referencing function are in different COMDAT groups. > > > > And is the referenced symbol non-public? If so, how does that work? > > > > I didn't check if it is public or private. It is OK for public, but not OK > for private if they are in different comdat groups. >
In GCC master source, when we force a comdat function symbol, which may be in the same comdat group or a different comdat group, into a constant pool, the symbol is always public. GCC never references a private comdat function symbol in a different comdat group. We just need to handle private COMDAT function symbol reference in the same comdat group by calling function_rodata_section. -- H.J.