[lldb-dev] [Bug 45902] New: Wrong Debug Information at O3

via lldb-dev lldb-dev at lists.llvm.org
Wed May 13 06:33:46 PDT 2020


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

            Bug ID: 45902
           Summary: Wrong Debug Information at O3
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: massarelli at diag.uniroma1.it
                CC: ditaliano at apple.com, jdevlieghere at apple.com,
                    llvm-bugs at lists.llvm.org

Debug information seems wrong at O3.
At line 7 variable j and k should not be visible. 

$ cat a.c
int a[56];
int b ;
int c[1] ;
int d[1][9][8] ;
void
e (f) {
 b = 
 b  & 5 ^ 
 a[b ^ f ];
}

void h (f) {
 long g = f;
 {
        b = b  & 5 ^ a[b ];
        b = b  & 5 ^ a[b ^ 8 ];
        b = b  & 5 ^ a[b ^ g ];
        b = b  & 5 ^ a[b ^ g ];
  }
  e (g & 5);
  e (g>>48 & 5);
  e (g>>56 & 5);
 }

int main ()
{
    int i, j, k,  dm ;
    {
            d[0][1][0] = 0;
    }
    printf("ciao");
    h(0);
    j = 0;
    for (; j < 9; j++)
    {
        k = 0;
        for (; k < 8; k++)
            h(d[0][j][k]);
    }
}

$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
c25b20c0f6c13d68dbc2e185764082d61ae4a132)
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
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 11.0.0
  clang revision c25b20c0f6c13d68dbc2e185764082d61ae4a132
  llvm revision c25b20c0f6c13d68dbc2e185764082d61ae4a132

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

$ lldb opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b -l 7
Breakpoint 1: 3 locations.
(lldb) r
Process 60 launched: 'opt' (x86_64)
Process 60 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.3
    frame #0: 0x0000000000400618 opt`main [inlined] e(f=0) at a.c:7:4
   4    int d[1][9][8] ;
   5    void
   6    e (f) {
-> 7     b = 
   8     b  & 5 ^ 
   9     a[b ^ f ];
   10   }
(lldb) frame var
(int) f = 0
(lldb) s
Process 60 stopped
* thread #1, name = 'opt', stop reason = step in
    frame #0: 0x000000000040061e opt`main at a.c:7:4
   4    int d[1][9][8] ;
   5    void
   6    e (f) {
-> 7     b = 
   8     b  & 5 ^ 
   9     a[b ^ f ];
   10   }
(lldb) frame var
(int) j = 0
(int) k = 0
(int) i = <no location, value may have been optimized out>

(int) dm = <no location, value may have been optimized out>

(lldb) 

$ gdb opt 
Breakpoint 1, e (f=0) at a.c:7
7        b = 
(gdb) frame var
#0  e (f=0) at a.c:7
7        b = 
(gdb) bt
#0  e (f=0) at a.c:7
#1  h (f=0) at a.c:22
#2  main () at a.c:32
(gdb) s
main () at a.c:38
38                  h(d[0][j][k]);
(gdb) frame var
#0  main () at a.c:38
38                  h(d[0][j][k]);
(gdb) c
Continuing.
ciao[Inferior 1 (process 153) exited normally]
(gdb)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200513/41eeee9d/attachment-0001.html>


More information about the lldb-dev mailing list