https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97937
Bug ID: 97937 Summary: Line numbers are missing from duplicated function Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: bernd.edlinger at hotmail dot de CC: marxin at gcc dot gnu.org Target Milestone: --- Consider this test case: $ cat test.c int test(void) { return 0; } int test1(void) { return 0; } struct s { int (*x) (void); int (*y) (void); }; struct s xxx = { test, test1 }; $ gcc -g -O2 -S test.c test.s: .file "test.c" .text .Ltext0: .p2align 4 .globl test .type test, @function test: .LFB0: .file 1 "test.c" .loc 1 2 1 view -0 .cfi_startproc .loc 1 3 3 view .LVU1 .loc 1 4 1 is_stmt 0 view .LVU2 xorl %eax, %eax ret .cfi_endproc .LFE0: .size test, .-test .p2align 4 .globl test1 .type test1, @function test1: .LFB3: .cfi_startproc xorl %eax, %eax ret .cfi_endproc The problem is that there are no line numbers in test1. That is caused by this statement in symtab-thunks.cc 428 if (force_gimple_thunk) 429 DECL_IGNORED_P (thunk_fndecl) = 1; #0 expand_thunk (node=0x7fffeee7edd0, output_asm_thunks=false, force_gimple_thunk=true) at ../../gcc-trunk/gcc/symtab-thunks.cc:429 #1 0x0000000000fca17b in cgraph_node::create_wrapper (this=0x7fffeee7edd0, target=0x7fffeee7ebb0) at ../../gcc-trunk/gcc/cgraphunit.c:2601 #2 0x000000000281d7bd in ipa_icf::sem_function::merge (this=0x46dfc90, alias_item=0x46c2880) at ../../gcc-trunk/gcc/ipa-icf.c:1299 #3 0x0000000002825672 in ipa_icf::sem_item_optimizer::merge_classes (this=0x4746390, prev_class_count=902, loaded_symbols=74) at ../../gcc-trunk/gcc/ipa-icf.c:3406 #4 0x00000000028220c8 in ipa_icf::sem_item_optimizer::execute (this=0x4746390) at ../../gcc-trunk/gcc/ipa-icf.c:2459 together with this in final.c: 2433 case NOTE_INSN_BEGIN_STMT: 2434 gcc_checking_assert (cfun->debug_nonbind_markers); 2435 if (!DECL_IGNORED_P (current_function_decl) 2436 && notice_source_line (insn, NULL)) (gdb) 2437 { 2438 output_source_line: 2439 (*debug_hooks->source_line) (last_linenum, last_columnnum, 2440 last_filename, last_discriminator, 2441 true); 2442 clear_next_view_needed (seen); 2443 } 2444 break; which prevents the line number from being included in the asm.