[llvm-bugs] [Bug 45153] New: Wrong debug info generated at -O3 (-O0 is correct)
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 9 08:36:32 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45153
Bug ID: 45153
Summary: Wrong debug info generated at -O3 (-O0 is correct)
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: DebugInfo
Assignee: unassignedbugs at nondot.org
Reporter: shuo.d at outlook.com
CC: jdevlieghere at apple.com, keith.walker at arm.com,
llvm-bugs at lists.llvm.org,
paul_robinson at playstation.sony.com
The expected output from lldb should be 20, but lldb outputs 0 when the program
is compiled with "-O3". It behaves correctly when the program is compiled with
"-O0".
In both cases, the debugger stops at line 7 and the tiny underscore is between
c and 0. I think this indicates that the debugger stops at the same breakpoint,
and in this case it should at least prints the same value. My understanding is
that the assignment operation of l_16 hasn't been executed, thus the correct
output should be 20.
$ cat abc.c
int a, b;
unsigned c;
int main() {
int l_16 = 0;
for (; l_16 < 20; l_16 = l_16 + 5)
;
l_16 = c = 0 // optimize_me_not0
^ a;
b = b & 1048575 ^ a;
}
$ cat cmds
b 7
r
p l_16
kill
q
$ clang-trunk -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
bdcbdb484829c518511eece0809cc8ce1baa73c8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ lldb-trunk -v
lldb version 11.0.0
clang revision bdcbdb484829c518511eece0809cc8ce1baa73c8
llvm revision bdcbdb484829c518511eece0809cc8ce1baa73c8
$ clang-trunk -g abc.c -O3
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/24200/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/24200/report/cmds'.
(lldb) b 7
Breakpoint 1: where = a.out`main + 17 at abc.c:7:12, address =
0x0000000000400491
(lldb) r
Process 5369 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400491 a.out`main at abc.c:7:12
4 int l_16 = 0;
5 for (; l_16 < 20; l_16 = l_16 + 5)
6 ;
-> 7 l_16 = c = 0 // optimize_me_not0
8 ^ a;
9 b = b & 1048575 ^ a;
10 }
Process 5369 launched: '/home/sding/LLDB-testing/reduce/24200/report/a.out'
(x86_64)
(lldb) p l_16
(int) $0 = 0
(lldb) kill
Process 5369 exited with status = 9 (0x00000009)
(lldb) q
$ clang-trunk -g abc.c -O0
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/24200/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/24200/report/cmds'.
(lldb) b 7
Breakpoint 1: where = a.out`main + 57 at abc.c:7:12, address =
0x00000000004004b9
(lldb) r
Process 6210 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00000000004004b9 a.out`main at abc.c:7:12
4 int l_16 = 0;
5 for (; l_16 < 20; l_16 = l_16 + 5)
6 ;
-> 7 l_16 = c = 0 // optimize_me_not0
8 ^ a;
9 b = b & 1048575 ^ a;
10 }
Process 6210 launched: '/home/sding/LLDB-testing/reduce/24200/report/a.out'
(x86_64)
(lldb) p l_16
(int) $0 = 20
(lldb) kill
Process 6210 exited with status = 9 (0x00000009)
(lldb) q
--
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/20200309/0e5d3c08/attachment.html>
More information about the llvm-bugs
mailing list