public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/97937] New: Line numbers are missing from duplicated function
@ 2020-11-22 15:14 bernd.edlinger at hotmail dot de
  2020-11-23  7:35 ` [Bug ipa/97937] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2020-11-22 15:14 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ipa/97937] [11 Regression] Line numbers are missing from duplicated function
  2020-11-22 15:14 [Bug ipa/97937] New: Line numbers are missing from duplicated function bernd.edlinger at hotmail dot de
@ 2020-11-23  7:35 ` rguenth at gcc dot gnu.org
  2020-11-23  7:53 ` hubicka at gcc dot gnu.org
  2021-05-06 14:39 ` cvs-commit at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-23  7:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97937

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org
   Target Milestone|---                         |11.0
           Keywords|                            |wrong-debug
            Summary|Line numbers are missing    |[11 Regression] Line
                   |from duplicated function    |numbers are missing from
                   |                            |duplicated function

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
It doesn't look like a thunk anyway - we seem to inline the function back?! 
Guess this is a case where we shouldn't ICF because it only degrades things (as
seen).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ipa/97937] [11 Regression] Line numbers are missing from duplicated function
  2020-11-22 15:14 [Bug ipa/97937] New: Line numbers are missing from duplicated function bernd.edlinger at hotmail dot de
  2020-11-23  7:35 ` [Bug ipa/97937] [11 Regression] " rguenth at gcc dot gnu.org
@ 2020-11-23  7:53 ` hubicka at gcc dot gnu.org
  2021-05-06 14:39 ` cvs-commit at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: hubicka at gcc dot gnu.org @ 2020-11-23  7:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97937

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
There is old PR on this

*** This bug has been marked as a duplicate of bug 63572 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ipa/97937] [11 Regression] Line numbers are missing from duplicated function
  2020-11-22 15:14 [Bug ipa/97937] New: Line numbers are missing from duplicated function bernd.edlinger at hotmail dot de
  2020-11-23  7:35 ` [Bug ipa/97937] [11 Regression] " rguenth at gcc dot gnu.org
  2020-11-23  7:53 ` hubicka at gcc dot gnu.org
@ 2021-05-06 14:39 ` cvs-commit at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-06 14:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97937

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Bernd Edlinger <edlinger@gcc.gnu.org>:

https://gcc.gnu.org/g:e69ac0203725fb8da83a1cc88d32191b7a0b2c0c

commit r12-574-ge69ac0203725fb8da83a1cc88d32191b7a0b2c0c
Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date:   Tue Jan 12 16:27:53 2021 +0100

    Add line debug info for virtual thunks

    There is no debug info when the DECL_IGNORED_P flag
    is set.  But sometimes we have the line info of the
    function decl, as in the case of on virtual thunks.
    So instead of no line info at all, we emit at least
    the location of the function decl.
    On the other side, there are DECL_IGNORED_P functions
    which do not have any source line info at all.
    Remove those from the debug_range info, to make it
    clear for the debugger that the line info for these
    functions is invalid.  This has the effect that the
    debugger will not step into the function without
    debug info.

    2021-05-06  Bernd Edlinger  <bernd.edlinger@hotmail.de>

            PR ipa/97937
            * debug.h (gcc_debug_hooks): Add set_ignored_loc function pointer.
            * dwarf2out.h (dw_fde_node::ignored_debug): New data item.
            * dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Add dummy
            set_ignored_loc callbacks.
            * debug.c (do_nothing_debug_hooks): Likewise.
            * vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
            * dwarf2out.c (text_section_used, cold_text_section_used): Remove.
            (in_text_section_p, last_text_label, last_cold_label,
            switch_text_ranges, switch_cold_ranges): New data items.
            (dwarf2out_note_section_used): Remove.
            (dwarf2out_begin_prologue): Set fde->ignored_debug and
            in_text_section_p.
            (mark_ignored_debug_section): New helper function.
            (dwarf2out_end_epilogue, dwarf2out_switch_text_section): Call
            mark_ignored_debug_section.
            (dwarf2_debug_hooks): Use dwarf2out_set_ignored_loc.
            (dwarf2_lineno_debug_hooks): Use dummy for set_ignored_loc.
            (size_of_aranges): Adjust formula for multi-part text ranges size.
            (output_aranges): Output multi-part text ranges.
            (dwarf2out_set_ignored_loc): New callback function.
            (dwarf2out_finish): Output multi-part text ranges.
            (dwarf2out_c_finalize): Clear new data items.
            * final.c (final_start_function_1): Call set_ignored_loc callback.
            (final_scan_insn_1): Likewise.
            * ggc-page.c (gt_ggc_mx): New helper function.
            * stringpool.c (gt_pch_nx): Likewise.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-06 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 15:14 [Bug ipa/97937] New: Line numbers are missing from duplicated function bernd.edlinger at hotmail dot de
2020-11-23  7:35 ` [Bug ipa/97937] [11 Regression] " rguenth at gcc dot gnu.org
2020-11-23  7:53 ` hubicka at gcc dot gnu.org
2021-05-06 14:39 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).