-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong debug info generated at -O2 (-O0 is correct) #43238
Comments
assigned to @kamleshbhalui |
I noticed that in the above test case, the breakpoint was set at line 5 and lldb stopped at line 6. Below, please see the same test case such that lldb stops at line 5 (and breakpoint was at line 5). $ cat abc.c $ cat cmds $ lldb-trunk -s cmds -batch a.out
Process 28371 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out' (x86_64) |
Looking at the IR, the most of the computations are dropped by instcombine because they're unused, and so is the dbg.value inst recording "l_1240 = b". It should have be left as an undef dbg.value. |
The case where lldb did not stop at line 5 has the source:
The case where it does stop has the source:
Note that the first case is a comparison whose result is not used, and That's why lldb will stop at line 5 in the second example. |
Are you going to write a patch for this? |
Davide, |
review at https://reviews.llvm.org/D69809 |
Extended Description
The expected output from lldb should be -1. However, compiled with "-O2", lldb outputs -8.
$ clang-trunk -v
clang version 10.0.0 (trunk 375507)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
$ clang-trunk -g abc.c -O2
$ lldb-trunk -s cmds -batch a.out
(lldb) b 5
Breakpoint 1: where = a.out`main + 7 at abc.c:6:1, address = 0x0000000000400487
(lldb) r
Process 12592 stopped
frame #0: 0x0000000000400487 a.out`main at abc.c:6:1
3 int b = --a, l_1240 = -8L;
4 l_1240 = b;
5 b > 0; // optimize_me_not
-> 6 }
Process 12592 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out' (x86_64)
(lldb) p l_1240
(int) $0 = -8
$ clang-trunk -g abc.c
$ lldb-trunk -s cmds -batch a.out
(lldb) b 5
Breakpoint 1: where = a.out`main + 42 at abc.c:6:1, address = 0x00000000004004aa
(lldb) r
Process 12562 stopped
frame #0: 0x00000000004004aa a.out`main at abc.c:6:1
3 int b = --a, l_1240 = -8L;
4 l_1240 = b;
5 b > 0; // optimize_me_not
-> 6 }
Process 12562 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out' (x86_64)
(lldb) p l_1240
(int) $0 = -1
$ cat abc.c
char a;
int main() {
int b = --a, l_1240 = -8;
l_1240 = b;
b > 0; // optimize_me_not
}
$ cat cmds
b 5
r
p l_1240
kill
q
The text was updated successfully, but these errors were encountered: