[llvm-bugs] [Bug 43986] New: Wrong debug info generated at -O3 (-O0 is correct)
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 12 17:53:33 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=43986
Bug ID: 43986
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 65530. However, compiled with "-O3",
lldb outputs 0.
$ clang-trunk -v
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
dd101539dac5e464042c04b72090741317d48c23)
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
abc.c:3:10: warning: non-void function does not return a value [-Wreturn-type]
int d() {}
^
abc.c:8:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
2 warnings generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/32255/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/32255/report/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`main + 13 [inlined] e + 13 at abc.c:9, address =
0x000000000040049d
(lldb) r
Process 32454 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x000000000040049d a.out`main [inlined] e(p_79=0) at abc.c:6:24
3 int d() {}
4 static int e(p_79) {
5 int f = 5 == c;
-> 6 if ((f &= p_79 != (c = 0) || d()) == a) // optimize_me_not0
7 b = p_79 = f;
8 }
9 int main() { e(65530); }
Process 32454 launched: '/home/sding/LLDB-testing/reduce/32255/report/a.out'
(x86_64)
(lldb) p p_79
(int) $0 = 0
(lldb) kill
Process 32454 exited with status = 9 (0x00000009)
(lldb) q
$ clang-trunk -g abc.c -O0
abc.c:3:10: warning: non-void function does not return a value [-Wreturn-type]
int d() {}
^
abc.c:8:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
2 warnings generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/32255/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/32255/report/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`e + 38 at abc.c:6:13, address = 0x00000000004004d6
(lldb) r
Process 1949 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00000000004004d6 a.out`e(p_79=65530) at abc.c:6:13
3 int d() {}
4 static int e(p_79) {
5 int f = 5 == c;
-> 6 if ((f &= p_79 != (c = 0) || d()) == a) // optimize_me_not0
7 b = p_79 = f;
8 }
9 int main() { e(65530); }
Process 1949 launched: '/home/sding/LLDB-testing/reduce/32255/report/a.out'
(x86_64)
(lldb) p p_79
(int) $0 = 65530
(lldb) kill
Process 1949 exited with status = 9 (0x00000009)
(lldb) q
$ cat abc.c
int a, b;
short c;
int d() {}
static int e(p_79) {
int f = 5 == c;
if ((f &= p_79 != (c = 0) || d()) == a) // optimize_me_not0
b = p_79 = f;
}
int main() { e(65530); }
$ cat cmds
b 6
r
p p_79
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/20191113/a1719917/attachment-0001.html>
More information about the llvm-bugs
mailing list