<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang generates wrong debug information at -O3"
href="https://bugs.llvm.org/show_bug.cgi?id=40795">40795</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang generates wrong debug information at -O3
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>qrzhang@gatech.edu
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>It also affects clang 7.0.
The correct output should be "l_34 = -5".
$ clang-trunk -v
clang version 9.0.0 (trunk 354437)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
$ cat abc.c
volatile int a;
unsigned b = 6;
int main() {
int l_34 = -5;
5 >= b && (l_34 = 0, a);
optimize_me_not();
}
$ cat outer.c
optimize_me_not() {}
$ cat cmds
b 6
r
p l_34
kill
q
<expected output>
$ clang-trunk abc.c outer.c -g
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/absozero/projects/LLDB-testing/reduce/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`main + 76 at abc.c:6:3, address =
0x00000000004004cc
(lldb) r
Process 2483 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00000000004004cc a.out`main at abc.c:6:3
3 int main() {
4 int l_34 = -5;
5 5 >= b && (l_34 = 0, a);
-> 6 optimize_me_not();
7 }
Process 2483 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) p l_34
(int) $0 = -5
(lldb) kill
Process 2483 exited with status = 9 (0x00000009)
(lldb) q
<wrong output at -O3>
$ clang-trunk abc.c outer.c -g -O3
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/absozero/projects/LLDB-testing/reduce/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`main + 16 at abc.c:6:3, address =
0x0000000000400490
(lldb) r
Process 3094 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400490 a.out`main at abc.c:6:3
3 int main() {
4 int l_34 = -5;
5 5 >= b && (l_34 = 0, a);
-> 6 optimize_me_not();
7 }
Process 3094 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) p l_34
(int) $0 = 0
(lldb) kill
Process 3094 exited with status = 9 (0x00000009)
(lldb) q</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>