<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Wrong backtrace and source line information at Og"
   href="https://bugs.llvm.org/show_bug.cgi?id=51750">51750</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong backtrace and source line information at Og
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>artuso@diag.uniroma1.it
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Comment:
When stepping on the "pushq %rax" assembly instruction the backtrace indicates
that we are inside the main function and the associated source line is wrong
(line 17, which is in function w). The "pushq %rax" instruction should point to
line 0.

Steps to reproduce bug:
root@b04800b37146:/home/stepping/output# clang -v
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
957334382cd12ec07b46c0ddfdcc220731f6d80f)
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
root@b04800b37146:/home/stepping/output# lldb -v
lldb version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a> revision
957334382cd12ec07b46c0ddfdcc220731f6d80f)
  clang revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
  llvm revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
root@b04800b37146:/home/stepping/output# cat a.c
volatile int a, c, e;
short d;
int f;
char g, h, k;
int j;
unsigned l;
static short m[] = {3, 3, 3, 3, 3, 3, 3};
int n;
int(o)() {
  f = o();
  if (f)
    m[2] = e;
}
void p() {
  int b[6];
  int i;
  for (i = 0; i < 6; i++)
    b[i] = 10;
  d = 0;
  for (; d <= 5; d++) {
    j |= 6;
    h = g++;
    b[2] | m[6] || (l = k);
  }
}
int main() {
  p();
  for (; n;)
    c = a * 7;
  a = j;
  a = h;
  a = m[g];
  printf("%X\n");
}
root@b04800b37146:/home/stepping/output# cat -n a.c
     1  volatile int a, c, e;
     2  short d;
     3  int f;
     4  char g, h, k;
     5  int j;
     6  unsigned l;
     7  static short m[] = {3, 3, 3, 3, 3, 3, 3};
     8  int n;
     9  int(o)() {
    10    f = o();
    11    if (f)
    12      m[2] = e;
    13  }
    14  void p() {
    15    int b[6];
    16    int i;
    17    for (i = 0; i < 6; i++)
    18      b[i] = 10;
    19    d = 0;
    20    for (; d <= 5; d++) {
    21      j |= 6;
    22      h = g++;
    23      b[2] | m[6] || (l = k);
    24    }
    25  }
    26  int main() {
    27    p();
    28    for (; n;)
    29      c = a * 7;
    30    a = j;
    31    a = h;
    32    a = m[g];
    33    printf("%X\n");
    34  }
root@b04800b37146:/home/stepping/output# lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/output/opt' (x86_64).
(lldb) b 0x400556
Breakpoint 1: address = 0x0000000000400556
(lldb) r
Process 50577 launched: '/home/stepping/output/opt' (x86_64)
FFFFE5F8
Process 50577 exited with status = 0 (0x00000000)
(lldb) b 0x400556
Breakpoint 2: where = opt`main + 22 [inlined] p + 6 at a.c:17:3, address =
0x0000000000400556
(lldb) r
Process 50585 launched: '/home/stepping/output/opt' (x86_64)
Process 50585 stopped
* thread #1, name = 'opt', stop reason = breakpoint 2.1
    frame #0: 0x0000000000400556 opt`main [inlined] p at a.c:17:3
   14   void p() {
   15     int b[6];
   16     int i;
-> 17     for (i = 0; i < 6; i++)
   18       b[i] = 10;
   19     d = 0;
   20     for (; d <= 5; d++) {
(lldb) di -l
opt`main:
    0x400554 <+20>: jne    0x400550                  ; <+16> [inlined] p at
a.c:17:17
->  0x400556 <+22>: pushq  %rax
    0x400557 <+23>: movl   0x200ae2(%rip), %r9d      ; j
    0x40055e <+30>: movw   $0x6, %dx
    0x400562 <+34>: movb   0x200adc(%rip), %al       ; g
    0x400568 <+40>: nopl   (%rax,%rax)
(lldb) bt
* thread #1, name = 'opt', stop reason = breakpoint 2.1
  * frame #0: 0x0000000000400556 opt`main [inlined] p at a.c:17:3
    frame #1: 0x0000000000400550 opt`main at a.c:27:3
    frame #2: 0x00007ffff7a03bf7 libc.so.6`__libc_start_main + 231
    frame #3: 0x000000000040040a opt`_start + 42</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>