[llvm-bugs] [Bug 46074] New: Wrong Line Information at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 26 06:01:44 PDT 2020


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

            Bug ID: 46074
           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 8 should not be hit.

$ cat a.c
typedef int int32_t;
int a, b, c;
static int32_t d;
static char e;
char(f)(char g) { return g >> a; }
int main() {
  for (; d < 9; ++d) {
    int32_t l_273[2][4][1];
    c = 0;
    for (; c < 4; c++)
      l_273[0][c][0] = 0;
    b = f(e--);
    l_273[0][3][0] |= b;
  }
}

$  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

$ clang -Og -g -o opt a.c

$ lldb opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main + 7 at a.c:7:3, address = 0x0000000000400497
(lldb) r
Process 65 launched: 'opt' (x86_64)
Process 65 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400497 opt`main at a.c:7:3
   4    static char e;
   5    char(f)(char g) { return g >> a; }
   6    int main() {
-> 7      for (; d < 9; ++d) {
   8        int32_t l_273[2][4][1];
   9        c = 0;
   10       for (; c < 4; c++)
(lldb) s
Process 65 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x00000000004004b0 opt`main at a.c:8:5
   5    char(f)(char g) { return g >> a; }
   6    int main() {
   7      for (; d < 9; ++d) {
-> 8        int32_t l_273[2][4][1];
   9        c = 0;
   10       for (; c < 4; c++)
   11         l_273[0][c][0] = 0;
(lldb) di
opt`main:
    0x400490 <+0>:   pushq  %r14
    0x400492 <+2>:   pushq  %rbx
    0x400493 <+3>:   subq   $0x28, %rsp
    0x400497 <+7>:   cmpb   $0x0, 0x200b92(%rip)      ; a + 3
    0x40049e <+14>:  jne    0x4004ef                  ; <+95> at a.c:15:1
    0x4004a0 <+16>:  movzbl 0x200b90(%rip), %r14d     ; e
    0x4004a8 <+24>:  xorl   %ebx, %ebx
    0x4004aa <+26>:  nopw   (%rax,%rax)
->  0x4004b0 <+32>:  leal   (%r14,%rbx), %eax
    0x4004b4 <+36>:  xorps  %xmm0, %xmm0
    0x4004b7 <+39>:  movaps %xmm0, (%rsp)
    0x4004bb <+43>:  movl   $0x4, 0x200b6f(%rip)      ; d
    0x4004c5 <+53>:  movsbl %al, %edi
    0x4004c8 <+56>:  callq  0x400480                  ; f at a.c:5
    0x4004cd <+61>:  movsbl %al, %eax
    0x4004d0 <+64>:  movl   %eax, 0x200b66(%rip)      ; b
    0x4004d6 <+70>:  addl   $-0x1, %ebx
    0x4004d9 <+73>:  cmpl   $-0x9, %ebx
    0x4004dc <+76>:  jne    0x4004b0                  ; <+32> at a.c:8:5
    0x4004de <+78>:  addl   %ebx, %r14d
    0x4004e1 <+81>:  movb   %r14b, 0x200b50(%rip)     ; e
    0x4004e8 <+88>:  movb   $0x1, 0x200b41(%rip)      ; a + 3
    0x4004ef <+95>:  xorl   %eax, %eax
    0x4004f1 <+97>:  addq   $0x28, %rsp
    0x4004f5 <+101>: popq   %rbx
    0x4004f6 <+102>: popq   %r14
    0x4004f8 <+104>: retq   
(lldb) s
Process 65 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x00000000004004b4 opt`main at a.c:11:22
   8        int32_t l_273[2][4][1];
   9        c = 0;
   10       for (; c < 4; c++)
-> 11         l_273[0][c][0] = 0;
   12       b = f(e--);
   13       l_273[0][3][0] |= b;
   14     }
(lldb) s
Process 65 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x00000000004004c5 opt`main at a.c:12:9
   9        c = 0;
   10       for (; c < 4; c++)
   11         l_273[0][c][0] = 0;
-> 12       b = f(e--);
   13       l_273[0][3][0] |= b;
   14     }
   15   }

-- 
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/20200526/5522454e/attachment.html>


More information about the llvm-bugs mailing list