[llvm-bugs] [Bug 46008] New: Wrong line information at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 20 08:59:32 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46008

            Bug ID: 46008
           Summary: Wrong line information at Og
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: massarelli at diag.uniroma1.it
                CC: ditaliano at apple.com, jdevlieghere at apple.com,
                    keith.walker at arm.com, llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

Line 7 should not be hit.

$ cat a.c
short a = 1;
int b, c;
void(d)() {}
int main() {
  int *p_5 = &c;
  for (; a <= 0; a = d)
    if ((*p_5))
      break;
  b = *p_5;
}

$  clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
268fa40daa151d3b4bff1df12b62e5dae94685d7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 11.0.0
  clang revision 268fa40daa151d3b4bff1df12b62e5dae94685d7
  llvm revision 268fa40daa151d3b4bff1df12b62e5dae94685d7

$ lldb opt 
(lldb) target create "opt"
Current executable set to '/home/stepping/output/opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main at a.c:6:12, address = 0x0000000000400490
(lldb) r
Process 334 launched: '/home/stepping/output/opt' (x86_64)
Process 334 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400490 opt`main at a.c:6:12
   3    void(d)() {}
   4    int main() {
   5      int *p_5 = &c;
-> 6      for (; a <= 0; a = d)
   7        if ((*p_5))
   8          break;
   9      b = *p_5;
(lldb) p a
(short) $0 = 1
(lldb) s
Process 334 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x0000000000400498 opt`main at a.c:7:10
   4    int main() {
   5      int *p_5 = &c;
   6      for (; a <= 0; a = d)
-> 7        if ((*p_5))
   8          break;
   9      b = *p_5;
   10   }
(lldb) di
opt`main:
    0x400490 <+0>:  cmpw   $0x0, 0x200b90(%rip)      ; __dso_handle + 5
->  0x400498 <+8>:  movl   0x200b92(%rip), %eax      ; opt.PT_LOAD[1]..bss + 4
    0x40049e <+14>: jg     0x4004c1                  ; <+49> at a.c:9:5
    0x4004a0 <+16>: testl  %eax, %eax
    0x4004a2 <+18>: jne    0x4004c1                  ; <+49> at a.c:9:5
    0x4004a4 <+20>: movl   $0x400480, %ecx           ; imm = 0x400480 
    0x4004a9 <+25>: nopl   (%rax)
    0x4004b0 <+32>: testw  %cx, %cx
    0x4004b3 <+35>: jle    0x4004b0                  ; <+32> at a.c:6:3
    0x4004b5 <+37>: movl   $0x400480, %ecx           ; imm = 0x400480 
    0x4004ba <+42>: movw   %cx, 0x200b67(%rip)       ; __dso_handle + 6
    0x4004c1 <+49>: movl   %eax, 0x200b6d(%rip)      ; b
    0x4004c7 <+55>: xorl   %eax, %eax
    0x4004c9 <+57>: retq   
(lldb) s
Process 334 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x000000000040049e opt`main at a.c:6:3
   3    void(d)() {}
   4    int main() {
   5      int *p_5 = &c;
-> 6      for (; a <= 0; a = d)
   7        if ((*p_5))
   8          break;
   9      b = *p_5;
(lldb) s
Process 334 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x00000000004004c1 opt`main at a.c:9:5
   6      for (; a <= 0; a = d)
   7        if ((*p_5))
   8          break;
-> 9      b = *p_5;
   10   }
(lldb) 

$ gdb opt
(gdb) b main
Breakpoint 1 at 0x400490: file a.c, line 6.
(gdb) r
Starting program: opt 

Breakpoint 1, main () at a.c:6
6         for (; a <= 0; a = d)
(gdb) s
7           if ((*p_5))
(gdb) s
6         for (; a <= 0; a = d)
(gdb) s
9         b = *p_5;
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200520/bb3f8499/attachment.html>


More information about the llvm-bugs mailing list