<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 - Source line mapped to a nop at Og"
   href="https://bugs.llvm.org/show_bug.cgi?id=51603">51603</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Source line mapped to a nop 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>Linux
          </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:
Line 24 is associated to a single nop instruction. The expected behaviour
should be to  point at line 0 when stepping on the nop.

Steps to reproduce bug:

root@ab3a2d7dacea:/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@ab3a2d7dacea:/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@ab3a2d7dacea:/home/stepping/output# cat a.c
static int a ;
short g_1835 ;
char b ;
unsigned safe_add_func_uint8_t_u_u(char c, char d )
{
  return c + d;
}
void  e()
            {
                for (; ; ++a)
                ;
            }
void  func_1()
{
    int f[] = {4,4,4};
    char g ;
            for (; b >= 0; b --)
                {
                            if (3 != a)
                    ;
                    else
                        if (g)
                                f[5] = 5;
                    for (g_1835 = 0; (g_1835 < 19); g_1835 =
safe_add_func_uint8_t_u_u(g_1835, 4))
                        {
                        g = 1;
                        for (; ; g ++)
                            if (f[g])
                                break;
                        }
                }
}
int main ()
{
    func_1();
}

root@ab3a2d7dacea:/home/stepping/output# cat -n a.c
     1  static int a ;
     2  short g_1835 ;
     3  char b ;
     4  unsigned safe_add_func_uint8_t_u_u(char c, char d )
     5  {
     6    return c + d;
     7  }
     8  void  e()
     9              {
    10                  for (; ; ++a)
    11                  ;
    12              }
    13  void  func_1()
    14  {
    15      int f[] = {4,4,4};
    16      char g ;
    17              for (; b >= 0; b --)
    18                  {
    19                              if (3 != a)
    20                      ;
    21                      else
    22                          if (g)
    23                                  f[5] = 5;
    24                      for (g_1835 = 0; (g_1835 < 19); g_1835 =
safe_add_func_uint8_t_u_u(g_1835, 4))
    25                          {
    26                          g = 1;
    27                          for (; ; g ++)
    28                              if (f[g])
    29                                  break;
    30                          }
    31                  }
    32  }
    33  int main ()
    34  {
    35      func_1();
    36  }


root@ab3a2d7dacea:/home/stepping/output# clang -g -Og a.c -o opt
a.c:23:33: warning: array index 5 is past the end of the array (which contains
3 elements) [-Warray-bounds]
                                f[5] = 5;
                                ^ ~
a.c:15:5: note: array 'f' declared here
    int f[] = {4,4,4};
    ^
1 warning generated.

root@ab3a2d7dacea:/home/stepping/output# lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/output/opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main [inlined] func_1 at a.c:17:20, address =
0x00000000004004f0
(lldb) r
Process 45 launched: '/home/stepping/output/opt' (x86_64)
Process 45 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004f0 opt`main [inlined] func_1 at a.c:17:20
   14   {
   15       int f[] = {4,4,4};
   16       char g ;
-> 17               for (; b >= 0; b --)
   18                   {
   19                               if (3 != a)
   20                       ;
(lldb) si
Process 45 stopped
* thread #1, name = 'opt', stop reason = instruction step into
    frame #0: 0x00000000004004f6 opt`main [inlined] func_1 at a.c:17:22
   14   {
   15       int f[] = {4,4,4};
   16       char g ;
-> 17               for (; b >= 0; b --)
   18                   {
   19                               if (3 != a)
   20                       ;
(lldb) si
Process 45 stopped
* thread #1, name = 'opt', stop reason = instruction step into
    frame #0: 0x00000000004004f8 opt`main [inlined] func_1 at a.c:17:13
   14   {
   15       int f[] = {4,4,4};
   16       char g ;
-> 17               for (; b >= 0; b --)
   18                   {
   19                               if (3 != a)
   20                       ;
(lldb) si
Process 45 stopped
* thread #1, name = 'opt', stop reason = instruction step into
    frame #0: 0x00000000004004fa opt`main [inlined] func_1 at a.c:17:13
   14   {
   15       int f[] = {4,4,4};
   16       char g ;
-> 17               for (; b >= 0; b --)
   18                   {
   19                               if (3 != a)
   20                       ;
(lldb) si
Process 45 stopped
* thread #1, name = 'opt', stop reason = instruction step into
    frame #0: 0x0000000000400500 opt`main [inlined] func_1 at a.c:0:13
   1    static int a ;
   2    short g_1835 ;
   3    char b ;
   4    unsigned safe_add_func_uint8_t_u_u(char c, char d )
   5    {
   6      return c + d;
   7    }
(lldb) si
Process 45 stopped
* thread #1, name = 'opt', stop reason = instruction step into
    frame #0: 0x0000000000400502 opt`main [inlined] func_1 at a.c:24:62
   21                       else
   22                           if (g)
   23                                   f[5] = 5;
-> 24                       for (g_1835 = 0; (g_1835 < 19); g_1835 =
safe_add_func_uint8_t_u_u(g_1835, 4))
   25                           {
   26                           g = 1;
   27                           for (; ; g ++)
(lldb) di -l
opt`main:
->  0x400502 <+18>: nopw   %cs:(%rax,%rax)
    0x40050c <+28>: nopl   (%rax)

   4    unsigned safe_add_func_uint8_t_u_u(char c, char d )
   5    {
** 6      return c + d;
   7    }
   8    void  e()

    0x400510 <+32>: movsbl %cl, %ecx

   22                           if (g)
   23                                   f[5] = 5;
** 24                       for (g_1835 = 0; (g_1835 < 19); g_1835 =
safe_add_func_uint8_t_u_u(g_1835, 4))
   25                           {
   26                           g = 1;

    0x400513 <+35>: addl   $0x4, %ecx
    0x400516 <+38>: cmpw   $0x13, %cx
    0x40051a <+42>: jl     0x400510                  ; <+32> [inlined]
safe_add_func_uint8_t_u_u + 14 at a.c:6:10

   15       int f[] = {4,4,4};
   16       char g ;
** 17               for (; b >= 0; b --)
   18                   {
   19                               if (3 != a)

    0x40051c <+44>: leal   -0x1(%rax), %ecx
    0x40051f <+47>: testb  %al, %al
(lldb) si
Process 45 stopped
* thread #1, name = 'opt', stop reason = instruction step into
    frame #0: 0x000000000040050c opt`main [inlined]
safe_add_func_uint8_t_u_u(c='\0', d='\x04') at a.c:0:13
   1    static int a ;
   2    short g_1835 ;
   3    char b ;
   4    unsigned safe_add_func_uint8_t_u_u(char c, char d )
   5    {
   6      return c + d;
   7    }
(lldb) di -l
opt`main:
    0x400500 <+16>: xorl   %ecx, %ecx
    0x400502 <+18>: nopw   %cs:(%rax,%rax)
->  0x40050c <+28>: nopl   (%rax)</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>