<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68898>68898</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Incorrect debug info generated at -O3 (-O0 is correct)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hemangdash
</td>
</tr>
</table>
<pre>
```
$ clang-trunk --version
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 1964118ace4926f4d103aa0538db1f1f5baa343a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
```
```
$ cat abc.c
int a[256];
int b, c;
char d;
int main() {
int e = 0;
for (; e < 256; e++)
a[e] = e;
short f;
char l_1029 = 9;
int *g = &c;
d++;
f = -1;
l_1029 = f ^ 52;
*g = *g != 0;
b = 5;
}
```
```
$ clang-trunk abc.c -g -O0
$ lldb-trunk ./a.out -s cmds
(lldb) target create "./a.out"
Current executable set to '/data2/hemang/test3/reduction/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/data2/hemang/test3/reduction/cmds'.
(lldb) b 14
Breakpoint 1: where = a.out`main + 107 at abc.c:14:9, address = 0x000000000000119b
(lldb) r
Process 539940 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x000055555555519b a.out`main at abc.c:14:9
11 d++;
12 f = -1;
13 l_1029 = f ^ 52;
-> 14 *g = *g != 0;
15 b = 5;
16 }
Process 539940 launched: '/data2/hemang/test3/reduction/a.out' (x86_64)
(lldb) p l_1029
(char) '\xcb'
(lldb) kill
Process 539940 exited with status = 9 (0x00000009) killed
(lldb) q
```
```
$ clang-trunk abc.c -g -O3
$ lldb-trunk ./a.out -s cmds
(lldb) target create "./a.out"
Current executable set to '/data2/hemang/test3/reduction/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/data2/hemang/test3/reduction/cmds'.
(lldb) b 14
Breakpoint 1: where = a.out`main + 902 at abc.c:14:11, address = 0x00000000000014b6
(lldb) r
Process 541323 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00005555555554b6 a.out`main at abc.c:14:11
11 d++;
12 f = -1;
13 l_1029 = f ^ 52;
-> 14 *g = *g != 0;
15 b = 5;
16 }
Process 541323 launched: '/data2/hemang/test3/reduction/a.out' (x86_64)
(lldb) p l_1029
(char) '\t'
(lldb) kill
Process 541323 exited with status = 9 (0x00000009) killed
(lldb) q
```
```
$ cat cmds
b 14
r
p l_1029
kill
q
```
The issue exists as early as clang-3.4.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV01v4zYQ_TXjy0ACOdTnwQc7XgF72h72vqAk6qORJZekNt5_X1CSbSUOkgYtGqCoYSDOvKfhG87MAySNaeteqS2EewgPGznaZtDbRh1lX5fSNJt8KH9tIWLLlx2A7YACLDrZ157VY_-InvdTadMO_QxPEC4h5InPfIZASWPtyYDYAWVAWd3aZsz9YjgCZV338_LHO-nhd1VYv24t8jQKOE9koYKUoiooORNSslAkZc4rXoW5lCIQEiidz_4uda0siB2ek-hHFHhj_9gPT73Xtf149up-XHiNVrLE41CqzrFPg2nPM_S1N1Z2nSoPrXYQUDYa7dQNheyAsrxdCn15La8G3V1JizIv_GIOtb1FCeGewgjCA4j9LZwDPWBxDRWN1Fg-Yxxl2wMlQClCvMQRHaIQxAHZlY1YDdrdO4j9BD6gO9H9A7SfvsulTWoUhIcpg1plMM2gLVaryCSp-8GZEyAOmK4wpwJoV08AUHQrBMvlyJW4ieXxVWiVtkIIv2BIK3SV2f0g_rLcfELDawTiwwf7tJrpqV_o1eh9WzG6rswXgg-USX8YLXoGi2NpLqzEkVx_7DSLWGglrUIguj4CRDP7YdRaud6dVTFamXcKjbJoBwSKgbJSWklA2byQQJlVxgqgTKtyLKxbuWvK2PV6nnqg1L-TUwzHo-xLNMOoC-VUu62MJ-kUz_Qvk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