public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/105070] New: Missing debug info for switch statement
@ 2022-03-27 16:27 liyd2021 at gmail dot com
  2022-03-28  7:46 ` [Bug debug/105070] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: liyd2021 at gmail dot com @ 2022-03-27 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105070
           Summary: Missing debug info for switch statement
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liyd2021 at gmail dot com
  Target Milestone: ---

Affected versions: gcc 11.1.0, since gcc 9

(terminal) $ gcc-9 -v
Using built-in specs.
COLLECT_GCC=gcc-9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
9.4.0-1ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-9-yTrUTS/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04)


Debugging the following program will directly hit "return 1" instead of the
"switch (x)" in this specific case.
Did not observe this problem on other switch-cases.

(terminal) $ cat a.c && gcc -g -OO a.c
extern void abort(void);

int foo(int x) {
  switch (x) {
  case 1:
  case 3:
  case 5:
    return 1;
  default:
    return 0;
  }
}

int main() {
  int i, r;
  for (i = 0; i < 6; i++) {
    r = foo(i);
    if(i == 1 || i == 3 || i == 5){
      if(r == 0){
        abort();
      }
    }
  }
  return 0;
}

--------------------

(terminal) $ gdb a.out
(gdb) b foo
Breakpoint 1 at 0x4011b3: file a.c, line 8.
(gdb) r
Breakpoint 1, foo (x=1) at a.c:8
8           return 1;
(gdb) c
Continuing.

Breakpoint 1, foo (x=3) at a.c:8
8           return 1;
(gdb) c
Continuing.

Breakpoint 1, foo (x=5) at a.c:8
8           return 1;

This bug seemed to be missing debug_line. 

(terminal) $ readelf --debug-dump=decodedline a.out
Contents of the .debug_line section:

CU: a.c:
File  Line    Starting address    View    Stmt
a.c      3            0x401185               x
a.c      8            0x4011b3               x  <-- line 4 is missing
a.c     10            0x4011ba               x
a.c     12            0x4011bf               x
a.c     14            0x4011c1               x

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

* [Bug debug/105070] [9/10/11/12 Regression] Missing debug info for switch statement
  2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
@ 2022-03-28  7:46 ` rguenth at gcc dot gnu.org
  2022-03-28  9:34 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-28  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Target Milestone|---                         |9.5
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
   Last reconfirmed|                            |2022-03-28
     Ever confirmed|0                           |1
            Summary|Missing debug info for      |[9/10/11/12 Regression]
                   |switch statement            |Missing debug info for
                   |                            |switch statement
           Priority|P3                          |P2

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Interestingly all line number info is lost:

int foo (int x)
{
  int D.1961;
  int _1;
  int _3;
  int _4;
  unsigned int _6;
  _Bool _7;
  long unsigned int _8;
  long unsigned int _9;
  _Bool _10;

  <bb 2> :
  _6 = (unsigned int) x_2(D);
  _7 = _6 > 5;
  if (_7 != 0)
    goto <bb 5>; [20.00%]
  else
    goto <bb 3>; [80.00%]

  <bb 3> :
  _8 = 42 >> _6;
  _9 = _8 & 1;
  _10 = _9 != 0;
  if (_10 != 0)
    goto <bb 4>; [60.00%]
  else
    goto <bb 5>; [40.00%]

  <bb 4> :
  [t.c:8:12] _3 = 1;
  [t.c:8:12] goto <bb 6>; [INV]

and the reason is the switchlower pass run at -O0 which does

beginning to process the following SWITCH statement (t.c:4) : -------
switch (x_2(D)) <default: <L3> [INV], case 1: <L0> [INV], case 3: <L0> [INV],
case 5: <L0> [INV]>

;; GIMPLE switch case clusters: BT:1-5
Removing basic block 6

but does not put any locations on the generated stmts.

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

* [Bug debug/105070] [9/10/11/12 Regression] Missing debug info for switch statement
  2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
  2022-03-28  7:46 ` [Bug debug/105070] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
@ 2022-03-28  9:34 ` cvs-commit at gcc dot gnu.org
  2022-03-28  9:53 ` [Bug debug/105070] [9/10/11 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-28  9:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r12-7843-gbc86a86a4f2c057bc0e0be94dcbb8c128ae7f717
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Mar 28 10:07:53 2022 +0200

    tree-optimization/105070 - annotate bit cluster tests with locations

    The following makes sure to annotate the tests generated by
    switch lowering bit-clustering with locations which otherwise
    can be completely lost even at -O0.

    2022-03-28  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/105070
            * tree-switch-conversion.h
            (bit_test_cluster::hoist_edge_and_branch_if_true): Add location
            argument.
            * tree-switch-conversion.cc
            (bit_test_cluster::hoist_edge_and_branch_if_true): Annotate
            cond with location.
            (bit_test_cluster::emit): Annotate all generated expressions
            with location.

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

* [Bug debug/105070] [9/10/11 Regression] Missing debug info for switch statement
  2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
  2022-03-28  7:46 ` [Bug debug/105070] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
  2022-03-28  9:34 ` cvs-commit at gcc dot gnu.org
@ 2022-03-28  9:53 ` rguenth at gcc dot gnu.org
  2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-28  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression]     |[9/10/11 Regression]
                   |Missing debug info for      |Missing debug info for
                   |switch statement            |switch statement
      Known to work|                            |12.0

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.

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

* [Bug debug/105070] [9/10/11 Regression] Missing debug info for switch statement
  2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-03-28  9:53 ` [Bug debug/105070] [9/10/11 " rguenth at gcc dot gnu.org
@ 2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
  2022-04-21 12:51 ` [Bug debug/105070] [9/10 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-07  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:57b62cd299a0ec257141349a114e52f7233be67b

commit r11-9782-g57b62cd299a0ec257141349a114e52f7233be67b
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Mar 28 10:07:53 2022 +0200

    tree-optimization/105070 - annotate bit cluster tests with locations

    The following makes sure to annotate the tests generated by
    switch lowering bit-clustering with locations which otherwise
    can be completely lost even at -O0.

    2022-03-28  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/105070
            * tree-switch-conversion.h
            (bit_test_cluster::hoist_edge_and_branch_if_true): Add location
            argument.
            * tree-switch-conversion.c
            (bit_test_cluster::hoist_edge_and_branch_if_true): Annotate
            cond with location.
            (bit_test_cluster::emit): Annotate all generated expressions
            with location.

    (cherry picked from commit bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717)

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

* [Bug debug/105070] [9/10 Regression] Missing debug info for switch statement
  2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
@ 2022-04-21 12:51 ` cvs-commit at gcc dot gnu.org
  2022-05-06 11:09 ` [Bug debug/105070] [9 " cvs-commit at gcc dot gnu.org
  2022-05-06 11:10 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-21 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r10-10542-gb285999440c000685c4e4dae9c2a9a8a8fe9e176
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Mar 28 10:07:53 2022 +0200

    tree-optimization/105070 - annotate bit cluster tests with locations

    The following makes sure to annotate the tests generated by
    switch lowering bit-clustering with locations which otherwise
    can be completely lost even at -O0.

    2022-03-28  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/105070
            * tree-switch-conversion.h
            (bit_test_cluster::hoist_edge_and_branch_if_true): Add location
            argument.
            * tree-switch-conversion.c
            (bit_test_cluster::hoist_edge_and_branch_if_true): Annotate
            cond with location.
            (bit_test_cluster::emit): Annotate all generated expressions
            with location.

    (cherry picked from commit bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717)

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

* [Bug debug/105070] [9 Regression] Missing debug info for switch statement
  2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-04-21 12:51 ` [Bug debug/105070] [9/10 " cvs-commit 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
  6 siblings, 0 replies; 8+ 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=105070

--- Comment #6 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:4be43dbbed4b217201cb395449a7682cd98301ce

commit r9-10045-g4be43dbbed4b217201cb395449a7682cd98301ce
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Mar 28 10:07:53 2022 +0200

    tree-optimization/105070 - annotate bit cluster tests with locations

    The following makes sure to annotate the tests generated by
    switch lowering bit-clustering with locations which otherwise
    can be completely lost even at -O0.

    2022-03-28  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/105070
            * tree-switch-conversion.h
            (bit_test_cluster::hoist_edge_and_branch_if_true): Add location
            argument.
            * tree-switch-conversion.c
            (bit_test_cluster::hoist_edge_and_branch_if_true): Annotate
            cond with location.
            (bit_test_cluster::emit): Annotate all generated expressions
            with location.

    (cherry picked from commit b285999440c000685c4e4dae9c2a9a8a8fe9e176)

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

* [Bug debug/105070] [9 Regression] Missing debug info for switch statement
  2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-05-06 11:09 ` [Bug debug/105070] [9 " cvs-commit at gcc dot gnu.org
@ 2022-05-06 11:10 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ 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=105070

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |9.4.0
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
      Known to work|                            |9.4.1

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-27 16:27 [Bug debug/105070] New: Missing debug info for switch statement liyd2021 at gmail dot com
2022-03-28  7:46 ` [Bug debug/105070] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
2022-03-28  9:34 ` cvs-commit at gcc dot gnu.org
2022-03-28  9:53 ` [Bug debug/105070] [9/10/11 " rguenth at gcc dot gnu.org
2022-04-07  8:58 ` cvs-commit at gcc dot gnu.org
2022-04-21 12:51 ` [Bug debug/105070] [9/10 " cvs-commit at gcc dot gnu.org
2022-05-06 11:09 ` [Bug debug/105070] [9 " 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).