public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/98656] New: switchlower_O0 drops line number of switch
@ 2021-01-13  9:42 vries at gcc dot gnu.org
  2021-01-13 10:03 ` [Bug debug/98656] [9/10/11 Regression] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-13  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98656
           Summary: switchlower_O0 drops line number of switch
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

[ Originally filed as gdb PR at
https://sourceware.org/bugzilla/show_bug.cgi?id=27179 ]

Consider test-case small.c.
...
$ cat -n small.c
     1  #include <stdio.h>
     2
     3  void foo (int x, int y)
     4  {
     5    switch (x) {
     6      case 0: break;
     7      case 1: break;
     8      case 2: break;
     9      case 3:
    10        for (int z = 0; z < ({ if (y) break; 5; }); z++)
    11            break;
    12      case 4: break;
    13          default: break;
    14    }
    15  }
    16
    17  int main ()
    18  {
    19    foo (1, 1);  // L1
    20    foo (2, 1);  // L2
    21    printf("hello world!");  // L3
    22    return 0;
    23  }
...

With gcc-8, we have a .loc with line number 5 representing the switch
statement:
...
$ gcc-8 -O0 -g small.c -save-temps
$ cat small.s
foo:
.LFB0:
        .file 1 "small.c"
        .loc 1 4 1
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        movl    %edi, -20(%rbp)
        movl    %esi, -24(%rbp)
        .loc 1 5 3
        cmpl    $4, -20(%rbp)
        ja      .L13
...

With gcc-9 that .loc disappeared:
...
foo:
.LFB0:
        .file 1 "small.c"
        .loc 1 4 1
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        movl    %edi, -20(%rbp)
        movl    %esi, -24(%rbp)
        cmpl    $4, -20(%rbp)
        ja      .L13
...
and that's still the case with gcc-11.

Culprit is switchlower_O0.

With this compilation:
...
$ rm -f *.c.*; gcc-11 -O0 -g small.c -fdump-tree-all-lineno -save-temps
...
we have at a-small.c.234t.cplxlower0:
...
  <bb 2> :
  [small.c:5:3] switch (x_1(D)) <[small.c:13:2] default: <L10> [INV],
[small.c:6:5] case 0: <L0> [INV], [small.c:7:5] case 1: <L1> [INV],
[small.c:8:5] case 2: <L2> [INV], [small.c:9:5] case 3: <L3> [INV],
[small.c:12:5] case 4: <L8> [INV]>
...
and at a-small.c.236t.switchlower_O0:
...
  <bb 2> :
  switch (x_1(D)) <[small.c:13:2] default: <L10> [0.00%], [small.c:6:5] case 0:
<L0> [20.00%], [small.c:7:5] case 1: <L1> [20.00%], [small.c:8:5] case 2: <L2>
[20.00%], [small.c:9:5] case 3: <L3> [20.00%], [small.c:12:5] case 4: <L8>
[20.00%]>
...

Note the dropped "[small.c:5:3]" in front of "switch".

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

* [Bug debug/98656] [9/10/11 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
@ 2021-01-13 10:03 ` rguenth at gcc dot gnu.org
  2021-01-13 10:53 ` vries at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-13 10:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.4
           Priority|P3                          |P2
            Summary|switchlower_O0 drops line   |[9/10/11 Regression]
                   |number of switch            |switchlower_O0 drops line
                   |                            |number of switch

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

* [Bug debug/98656] [9/10/11 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
  2021-01-13 10:03 ` [Bug debug/98656] [9/10/11 Regression] " rguenth at gcc dot gnu.org
@ 2021-01-13 10:53 ` vries at gcc dot gnu.org
  2021-01-13 12:07 ` marxin at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-13 10:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 49959
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49959&action=edit
Tentative patch

Using this tentative patch, I get back the .loc for line number 5:
...
foo:
.LFB0:
        .file 1 "small.c"
        .loc 1 4 1
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        movl    %edi, -20(%rbp)
        movl    %esi, -24(%rbp)
        .loc 1 5 3
        cmpl    $4, -20(%rbp)
        ja      .L13
...

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

* [Bug debug/98656] [9/10/11 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
  2021-01-13 10:03 ` [Bug debug/98656] [9/10/11 Regression] " rguenth at gcc dot gnu.org
  2021-01-13 10:53 ` vries at gcc dot gnu.org
@ 2021-01-13 12:07 ` marxin at gcc dot gnu.org
  2021-01-19 14:00 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-01-13 12:07 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-01-13
     Ever confirmed|0                           |1

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #1)
> Created attachment 49959 [details]
> Tentative patch
> 
> Using this tentative patch, I get back the .loc for line number 5:
> ...
> foo:
> .LFB0:
>         .file 1 "small.c"
>         .loc 1 4 1
>         .cfi_startproc
>         pushq   %rbp
>         .cfi_def_cfa_offset 16
>         .cfi_offset 6, -16
>         movq    %rsp, %rbp
>         .cfi_def_cfa_register 6
>         movl    %edi, -20(%rbp)
>         movl    %esi, -24(%rbp)
>         .loc 1 5 3
>         cmpl    $4, -20(%rbp)
>         ja      .L13
> ...

I support the patch Tom.
Thanks for looking into it.

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

* [Bug debug/98656] [9/10/11 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-01-13 12:07 ` marxin at gcc dot gnu.org
@ 2021-01-19 14:00 ` jakub at gcc dot gnu.org
  2021-02-05  9:51 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-19 14:00 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
LGTM, please post to gcc-patches.

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

* [Bug debug/98656] [9/10/11 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-01-19 14:00 ` jakub at gcc dot gnu.org
@ 2021-02-05  9:51 ` marxin at gcc dot gnu.org
  2021-02-05 12:26 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-02-05  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
I'm going to test the patch and install it.

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

* [Bug debug/98656] [9/10/11 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-02-05  9:51 ` marxin at gcc dot gnu.org
@ 2021-02-05 12:26 ` cvs-commit at gcc dot gnu.org
  2021-02-05 12:26 ` [Bug debug/98656] [9/10 " marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-05 12:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:4ede02a5f2af1205434f0e05aaaeff762b24e329

commit r11-7122-g4ede02a5f2af1205434f0e05aaaeff762b24e329
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 5 10:36:38 2021 +0100

    debug: fix switch lowering debug info

    gcc/ChangeLog:

            PR debug/98656
            * tree-switch-conversion.c (jump_table_cluster::emit): Add loc
            argument.
            (bit_test_cluster::emit): Reuse location_t for newly created
            gswitch statement.
            (switch_decision_tree::try_switch_expansion): Preserve
            location_t.
            * tree-switch-conversion.h: Change function signatures.

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

* [Bug debug/98656] [9/10 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-02-05 12:26 ` cvs-commit at gcc dot gnu.org
@ 2021-02-05 12:26 ` marxin at gcc dot gnu.org
  2021-03-03  8:57 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-02-05 12:26 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |11.0
            Summary|[9/10/11 Regression]        |[9/10 Regression]
                   |switchlower_O0 drops line   |switchlower_O0 drops line
                   |number of switch            |number of switch

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed on master so far.

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

* [Bug debug/98656] [9/10 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-02-05 12:26 ` [Bug debug/98656] [9/10 " marxin at gcc dot gnu.org
@ 2021-03-03  8:57 ` cvs-commit at gcc dot gnu.org
  2021-03-03  8:58 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-03  8:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Martin Liska
<marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:186573a26a19e6e6523d86739248953042735372

commit r10-9404-g186573a26a19e6e6523d86739248953042735372
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 5 10:36:38 2021 +0100

    debug: fix switch lowering debug info

    gcc/ChangeLog:

            PR debug/98656
            * tree-switch-conversion.c (jump_table_cluster::emit): Add loc
            argument.
            (bit_test_cluster::emit): Reuse location_t for newly created
            gswitch statement.
            (switch_decision_tree::try_switch_expansion): Preserve
            location_t.
            * tree-switch-conversion.h: Change function signatures.

    (cherry picked from commit 4ede02a5f2af1205434f0e05aaaeff762b24e329)

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

* [Bug debug/98656] [9/10 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-03-03  8:57 ` cvs-commit at gcc dot gnu.org
@ 2021-03-03  8:58 ` marxin at gcc dot gnu.org
  2022-05-06 11:09 ` cvs-commit at gcc dot gnu.org
  2022-05-06 11:10 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-03-03  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed for gcc-10.

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

* [Bug debug/98656] [9/10 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-03-03  8:58 ` marxin at gcc dot gnu.org
@ 2022-05-06 11:09 ` cvs-commit at gcc dot gnu.org
  2022-05-06 11:10 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-06 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:05639c8bcc33d2d9a0b5ff787311b4d8fa904f06

commit r9-10044-g05639c8bcc33d2d9a0b5ff787311b4d8fa904f06
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 5 10:36:38 2021 +0100

    debug: fix switch lowering debug info

    gcc/ChangeLog:

            PR debug/98656
            * tree-switch-conversion.c (jump_table_cluster::emit): Add loc
            argument.
            (bit_test_cluster::emit): Reuse location_t for newly created
            gswitch statement.
            (switch_decision_tree::try_switch_expansion): Preserve
            location_t.
            * tree-switch-conversion.h: Change function signatures.

    (cherry picked from commit 4ede02a5f2af1205434f0e05aaaeff762b24e329)

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

* [Bug debug/98656] [9/10 Regression] switchlower_O0 drops line number of switch
  2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-05-06 11:09 ` cvs-commit at gcc dot gnu.org
@ 2022-05-06 11:10 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-06 11:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |10.2.1, 9.4.1
      Known to fail|                            |9.4.0

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Now also on the GCC 9 branch.

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

end of thread, other threads:[~2022-05-06 11:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  9:42 [Bug debug/98656] New: switchlower_O0 drops line number of switch vries at gcc dot gnu.org
2021-01-13 10:03 ` [Bug debug/98656] [9/10/11 Regression] " rguenth at gcc dot gnu.org
2021-01-13 10:53 ` vries at gcc dot gnu.org
2021-01-13 12:07 ` marxin at gcc dot gnu.org
2021-01-19 14:00 ` jakub at gcc dot gnu.org
2021-02-05  9:51 ` marxin at gcc dot gnu.org
2021-02-05 12:26 ` cvs-commit at gcc dot gnu.org
2021-02-05 12:26 ` [Bug debug/98656] [9/10 " marxin at gcc dot gnu.org
2021-03-03  8:57 ` cvs-commit at gcc dot gnu.org
2021-03-03  8:58 ` marxin at gcc dot gnu.org
2022-05-06 11:09 ` cvs-commit at gcc dot gnu.org
2022-05-06 11:10 ` rguenth 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).