public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/44205]  New: Wrong .debug_line for -O0 -g
@ 2010-05-19 22:49 jan dot kratochvil at redhat dot com
  2010-05-20 13:27 ` [Bug debug/44205] " jakub at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-05-19 22:49 UTC (permalink / raw)
  To: gcc-bugs

extern int i;
void
f (void)
{
  if (i)
    {
      if (i)
        i = 0;
      else
        i = 1;
    }
  else
    i = 2;
}

gcc -c -g
objdump -dS

        i = 0;
  18:   c7 05 00 00 00 00 00    movl   $0x0,0x0(%rip)        # 22 <f+0x22>
  1f:   00 00 00
      else
        i = 1;
  22:   eb 16                   jmp    3a <f+0x3a>
  24:   c7 05 00 00 00 00 01    movl   $0x1,0x0(%rip)        # 2e <f+0x2e>
  2b:   00 00 00
  2e:   eb 0a                   jmp    3a <f+0x3a>

jmp at offset 22 should belong to the "i = 0;" line.

Problem reproduced on:
gcc (GCC) 4.4.5 20100519 (prerelease)
gcc (GCC) 4.5.1 20100519 (prerelease)
gcc (GCC) 4.6.0 20100519 (experimental)
gcc-4.4.3-4.fc12.x86_64

Correct output on:
gcc-4.1.2-48.el5.x86_64

This will cause GDB to skip the line on `step' (which is a workaround in GDB
for missing is_stmt info).

Can GCC use its own new gdb guality framework to test it on its own?
There was before: PR debug/29609, PR debug/36690, PR debug/37616


-- 
           Summary: Wrong .debug_line for -O0 -g
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jan dot kratochvil at redhat dot com
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

* [Bug debug/44205] Wrong .debug_line for -O0 -g
  2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
@ 2010-05-20 13:27 ` jakub at gcc dot gnu dot org
  2010-05-20 14:44 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-20 13:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2010-05-20 13:27 -------
So, we have:
<bb 3>:
  [pr44205.c : 7:11] i.1_2 = i;
  [pr44205.c : 7:10] if (i.1_2 != 0)
    goto <bb 4>;
  else
    goto <bb 5>;

<bb 4>:
  [pr44205.c : 8:4] i = 0;
  goto <bb 6>;

<bb 5>:
  [pr44205.c : 10:4] i = 1;

<bb 6>:
  goto <bb 8>;

<bb 7>:
  [pr44205.c : 13:7] i = 2;

<bb 8>:
  [pr44205.c : 14:1] return;

in *.optimized dump which roughly corresponds to the first goto after i = 0
being on line 6 and then another goto on line 8.  Then during cfgcleanup mode
the jump is forwarded and just one of the locations is kept.

Now, either we'd need for -O0 to prevent jump forwarding when the locus is
different (or add a nop with one locus followed by jump with the second locus),
which would lead to gdb seeing movl $0, i; nop; on line 8 and jmp ... on line
10 (or movl $0, i; jmp 1f; on line 8 and movl $1, i; 1: jmp 3f; on line 10.
Or we need to do something already during gimplification and for nested if/else
if if(){}else{} isn't followed by any other statement and is inside of then
block of another if, ensure the branch goes stright to the last label instead
of hopping through some pad in the middle.  Only that would ensure movl $0, i;
jmp 3f; is on line 8 and that line 14 is immediately next insn after that.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

* [Bug debug/44205] Wrong .debug_line for -O0 -g
  2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
  2010-05-20 13:27 ` [Bug debug/44205] " jakub at gcc dot gnu dot org
@ 2010-05-20 14:44 ` jakub at gcc dot gnu dot org
  2010-05-20 16:04 ` jan dot kratochvil at redhat dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-20 14:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2010-05-20 14:44 -------
Created an attachment (id=20711)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20711&action=view)
gcc46-pr44205.patch

Doing it at gimplification time would be actually very hard, we only create the
continue label after then block is gimplified and only if it could fall
through.

Here is an attempt to fix this by removing forwarder blocks even at -O0 during
tree cfg cleanup if they don't care any useful location info (either everything
is UNKNOWN_LOCATION as in this testcase, or everything has the same location).
The goto to the cont label intentionally has no location:
              g = gimple_build_goto (label_cont);

              /* GIMPLE_COND's are very low level; they have embedded
                 gotos.  This particular embedded goto should not be marked
                 with the location of the original COND_EXPR, as it would
                 correspond to the COND_EXPR's condition, not the ELSE or the
                 THEN arms.  To avoid marking it with the wrong location, flag
                 it as "no location".  */
              gimple_set_do_not_emit_location (g);
and nothing else on the edges here has any locus either, so I believe nothing
is lost by removing the forwarder block.  We then avoid removing the forwarder
block at RTL cleanup time when the extra jump already has some, in this case
undesirable, location.

This patch definitely needs testing on gdb testsuite if it doesn't regress
anything at -O0 -g.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

* [Bug debug/44205] Wrong .debug_line for -O0 -g
  2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
  2010-05-20 13:27 ` [Bug debug/44205] " jakub at gcc dot gnu dot org
  2010-05-20 14:44 ` jakub at gcc dot gnu dot org
@ 2010-05-20 16:04 ` jan dot kratochvil at redhat dot com
  2010-05-21  9:27 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-05-20 16:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jan dot kratochvil at redhat dot com  2010-05-20 16:03 -------
No regressions for FSF GDB HEAD x86_64-linux-gnu with FSF GCC HEAD.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

* [Bug debug/44205] Wrong .debug_line for -O0 -g
  2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
                   ` (2 preceding siblings ...)
  2010-05-20 16:04 ` jan dot kratochvil at redhat dot com
@ 2010-05-21  9:27 ` jakub at gcc dot gnu dot org
  2010-05-21  9:28 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-21  9:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2010-05-21 09:26 -------
Subject: Bug 44205

Author: jakub
Date: Fri May 21 09:26:31 2010
New Revision: 159652

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159652
Log:
        PR debug/44205
        * tree-cfgcleanup.c (tree_forwarder_block_p): Return false if
        at -O0 goto_locus of any of the incoming edges differs from
        goto_locus of outgoing edge, or gimple_location of any of the
        labels differs.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-cfgcleanup.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

* [Bug debug/44205] Wrong .debug_line for -O0 -g
  2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
                   ` (3 preceding siblings ...)
  2010-05-21  9:27 ` jakub at gcc dot gnu dot org
@ 2010-05-21  9:28 ` jakub at gcc dot gnu dot org
  2010-05-21  9:30 ` jakub at gcc dot gnu dot org
  2010-05-21  9:35 ` [Bug debug/44205] [4.4/4.5/4.6 Regression] " jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-21  9:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jakub at gcc dot gnu dot org  2010-05-21 09:27 -------
Subject: Bug 44205

Author: jakub
Date: Fri May 21 09:27:30 2010
New Revision: 159653

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159653
Log:
        PR debug/44205
        * tree-cfgcleanup.c (tree_forwarder_block_p): Return false if
        at -O0 goto_locus of any of the incoming edges differs from
        goto_locus of outgoing edge, or gimple_location of any of the
        labels differs.

Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/tree-cfgcleanup.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

* [Bug debug/44205] Wrong .debug_line for -O0 -g
  2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
                   ` (4 preceding siblings ...)
  2010-05-21  9:28 ` jakub at gcc dot gnu dot org
@ 2010-05-21  9:30 ` jakub at gcc dot gnu dot org
  2010-05-21  9:35 ` [Bug debug/44205] [4.4/4.5/4.6 Regression] " jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-21  9:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2010-05-21 09:30 -------
Subject: Bug 44205

Author: jakub
Date: Fri May 21 09:30:07 2010
New Revision: 159654

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159654
Log:
        PR debug/44205
        * tree-cfgcleanup.c (tree_forwarder_block_p): Return false if
        at -O0 goto_locus of any of the incoming edges differs from
        goto_locus of outgoing edge, or gimple_location of any of the
        labels differs.

Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/tree-cfgcleanup.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

* [Bug debug/44205] [4.4/4.5/4.6 Regression] Wrong .debug_line for -O0 -g
  2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
                   ` (5 preceding siblings ...)
  2010-05-21  9:30 ` jakub at gcc dot gnu dot org
@ 2010-05-21  9:35 ` jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-21  9:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2010-05-21 09:33 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
            Summary|Wrong .debug_line for -O0 -g|[4.4/4.5/4.6 Regression]
                   |                            |Wrong .debug_line for -O0 -g
   Target Milestone|---                         |4.4.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44205


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

end of thread, other threads:[~2010-05-21  9:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-19 22:49 [Bug debug/44205] New: Wrong .debug_line for -O0 -g jan dot kratochvil at redhat dot com
2010-05-20 13:27 ` [Bug debug/44205] " jakub at gcc dot gnu dot org
2010-05-20 14:44 ` jakub at gcc dot gnu dot org
2010-05-20 16:04 ` jan dot kratochvil at redhat dot com
2010-05-21  9:27 ` jakub at gcc dot gnu dot org
2010-05-21  9:28 ` jakub at gcc dot gnu dot org
2010-05-21  9:30 ` jakub at gcc dot gnu dot org
2010-05-21  9:35 ` [Bug debug/44205] [4.4/4.5/4.6 Regression] " jakub at gcc dot gnu dot 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).