[llvm-bugs] [Bug 43970] New: Wrong debug info generated at -O3 (-O0 is correct)
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Nov 11 15:43:09 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=43970
Bug ID: 43970
Summary: Wrong debug info generated at -O3 (-O0 is correct)
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: shuo.d at outlook.com
CC: davide at freebsd.org, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
The expected output from lldb should be 2. However, compiled with "-O3", lldb
outputs -1.
$ clang-trunk -v
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
af5df83671bc4d94bddf33381430b6291d95a4fc)
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
$ 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/30416/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/30416/report/cmds'.
(lldb) b 11
Breakpoint 1: where = a.out`main + 7 at abc.c:11:10, address =
0x0000000000400487
(lldb) r
Process 28860 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400487 a.out`main at abc.c:11:10
8 p_63 = 2;
9 for (; p_63 >= 0; p_63--) {
10 int *d = &a;
-> 11 *d |= 1; // optimize_me_not0
12 }
13 break;
14 }
Process 28860 launched: '/home/sding/LLDB-testing/reduce/30416/report/a.out'
(x86_64)
(lldb) p p_63
(int) $0 = -1
(lldb) kill
Process 28860 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/30416/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/30416/report/cmds'.
(lldb) b 11
Breakpoint 1: where = a.out`main + 64 at abc.c:11:8, address =
0x00000000004004c0
(lldb) r
Process 1317 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00000000004004c0 a.out`main at abc.c:11:8
8 p_63 = 2;
9 for (; p_63 >= 0; p_63--) {
10 int *d = &a;
-> 11 *d |= 1; // optimize_me_not0
12 }
13 break;
14 }
Process 1317 launched: '/home/sding/LLDB-testing/reduce/30416/report/a.out'
(x86_64)
(lldb) p p_63
(int) $0 = 2
(lldb) kill
Process 1317 exited with status = 9 (0x00000009)
(lldb) q
$ cat abc.c
int a;
volatile short b;
int main() {
for (;;) {
int p_63;
int *c = &a;
b;
p_63 = 2;
for (; p_63 >= 0; p_63--) {
int *d = &a;
*d |= 1; // optimize_me_not0
}
break;
}
}
$ cat cmds
b 11
r
p p_63
kill
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/20191111/00fc27da/attachment-0001.html>
More information about the llvm-bugs
mailing list