[llvm-bugs] [Bug 51603] New: Source line mapped to a nop at Og

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 24 08:19:07 PDT 2021


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

            Bug ID: 51603
           Summary: Source line mapped to a nop at Og
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: artuso at diag.uniroma1.it
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

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 at ab3a2d7dacea:/home/stepping/output# clang -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
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 at ab3a2d7dacea:/home/stepping/output# lldb -v
lldb version 14.0.0 (https://github.com/llvm/llvm-project.git revision
957334382cd12ec07b46c0ddfdcc220731f6d80f)
  clang revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
  llvm revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
root at 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 at 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 at 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 at 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)

-- 
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/20210824/7ceb3662/attachment.html>


More information about the llvm-bugs mailing list