[llvm-bugs] [Bug 44371] New: Wrong debug info generated at -O3 (-O0 is correct)
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 24 02:58:31 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44371
Bug ID: 44371
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: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
The expected output from lldb should be 65535. However, compiled with "-O3",
lldb outputs 61440.
$ clang-trunk -v
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
e0d855b39974bc40dee0f722884894098be6d420)
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:15:1: warning: non-void function does not return a value in all control
paths [-Wreturn-type]
}
^
1 warning generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to
'/home/sding/LLDB-testing/reduce-new-llvm/15179/REPORT/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in
'/home/sding/LLDB-testing/reduce-new-llvm/15179/REPORT/cmds'.
(lldb) b 19
Breakpoint 1: 3 locations.
(lldb) r
Process 19844 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.3
frame #0: 0x0000000000400543 a.out`main [inlined] o(p_28=61440) at
abc.c:19:7
16 void o(p_28) {
17 i = (0 == h) - 2;
18 k = n(i ^ 43176 ^ p_28, 8);
-> 19 if (d) // optimize_me_not0
20 g = 0;
21 }
22 int main() { p(); }
Process 19844 launched:
'/home/sding/LLDB-testing/reduce-new-llvm/15179/REPORT/a.out' (x86_64)
(lldb) p p_28
(int) $0 = 61440
(lldb) kill
Process 19844 exited with status = 9 (0x00000009)
(lldb) q
$ clang-trunk -g abc.c -O0
abc.c:15:1: warning: non-void function does not return a value in all control
paths [-Wreturn-type]
}
^
1 warning generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to
'/home/sding/LLDB-testing/reduce-new-llvm/15179/REPORT/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in
'/home/sding/LLDB-testing/reduce-new-llvm/15179/REPORT/cmds'.
(lldb) b 19
Breakpoint 1: where = a.out`o + 75 at abc.c:19:7, address = 0x00000000004005bb
(lldb) r
Process 19871 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00000000004005bb a.out`o(p_28=65535) at abc.c:19:7
16 void o(p_28) {
17 i = (0 == h) - 2;
18 k = n(i ^ 43176 ^ p_28, 8);
-> 19 if (d) // optimize_me_not0
20 g = 0;
21 }
22 int main() { p(); }
Process 19871 launched:
'/home/sding/LLDB-testing/reduce-new-llvm/15179/REPORT/a.out' (x86_64)
(lldb) p p_28
(int) $0 = 65535
(lldb) kill
Process 19871 exited with status = 9 (0x00000009)
(lldb) q
$ cat abc.c
int a, d, g, h, i;
static short e = -1L, f, j;
short k;
short(n)(short b, int c) { return b < 0 ? b : b >> c; }
void o(int);
int p() {
char l = 0;
j = e ? e : a;
unsigned short m = j;
o(m);
for (; l <= 7; l++)
if (l)
return f;
e = 0;
}
void o(p_28) {
i = (0 == h) - 2;
k = n(i ^ 43176 ^ p_28, 8);
if (d) // optimize_me_not0
g = 0;
}
int main() { p(); }
$ cat cmds
b 19
r
p p_28
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/20191224/0f4db497/attachment.html>
More information about the llvm-bugs
mailing list