[llvm-bugs] [Bug 46029] New: inconsistent behaviors at -O3 (-O0 is correct)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 21 18:50:13 PDT 2020


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

            Bug ID: 46029
           Summary: inconsistent behaviors at -O3 (-O0 is correct)
           Product: lldb
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: yangyibiao at hust.edu.cn
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

Created attachment 23515
  --> https://bugs.llvm.org/attachment.cgi?id=23515&action=edit
the binary

$ clang --version
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ lldb --version
lldb version 11.0.0
  clang revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af
  llvm revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af


$ clang -g -O3 small.c

$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b 11
Breakpoint 1: where = a.out`foo + 214 at small.c:11:7, address =
0x0000000000401206
(lldb) r
Process 295458 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 295458 exited with status = 0 (0x00000000) 
(lldb) q


/************************************
As showed, when setting breakpoint on Line 11, lldb exit directly.
However, when step-i, Line 11 is hit by lldb as follow:
************************************/


$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main + 1 at small.c:15:3, address =
0x00000000004013b1
(lldb) r
Process 295500 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 295500 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004013b1 a.out`main at small.c:15:3
   12   }
   13   
   14   int main() { 
-> 15     foo(2, 0);
   16     return 0;
   17   }
   18   
(lldb) si -c 19
Process 295500 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x000000000040135e a.out`foo(r=4210760, n=0) at small.c:11:14
   8    
   9      while(i-->0)
   10       if(n==0 || c[r+i]==0)
-> 11         g[r+i] = 0;
   12   }
   13   
   14   int main() { 
(lldb)


$ cat small.c
int g[10], c[10];

__attribute__ ((noinline)) 
void foo(int r, int n) {
  int i=0;
  if(r>g[r])
    i=r;

  while(i-->0)
    if(n==0 || c[r+i]==0)
      g[r+i] = 0;
}

int main() { 
  foo(2, 0);
  return 0;
}

-- 
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/20200522/7e5620d1/attachment.html>


More information about the llvm-bugs mailing list