<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 - Wrong debug info generated at -O3 (-O0 is correct)"
href="https://bugs.llvm.org/show_bug.cgi?id=46006">46006</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong debug info generated at -O3 (-O0 is correct)
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>yangyibiao@hust.edu.cn
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
</td>
</tr></table>
<p>
<div>
<pre>lldb outputs 0 when the program is compiled with "-O3". It behaves correctly
when the program is compiled with "-O0".
$ cat small.c
void foo(int *a) {
(*a)++;
}
int main() {
int a = 0;
foo (&a);
return 0;
}
$ cat cmds
b 8
r
p a
$ clang --version
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ lldb --version
lldb version 11.0.0
clang revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af
llvm revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af
$ clang -g -O0 small.c
$ lldb -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/yibiao/Debugger/cmds'.
(lldb) b 8
Breakpoint 1: where = a.out`main + 33 at small.c:8:3, address =
0x0000000000401151
(lldb) r
Process 3458 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000401151 a.out`main at small.c:8:3
5 int main() {
6 int a = 0;
7 foo (&a);
-> 8 return 0;
9 }
Process 3458 launched: '/home/yibiao/Debugger/a.out' (x86_64)
(lldb) p a
(int) $0 = 1
$ clang -g -O3 small.c
$ lldb -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/yibiao/Debugger/cmds'.
(lldb) b 8
Breakpoint 1: where = a.out`main at small.c:8:3, address = 0x0000000000401120
(lldb) r
Process 3563 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000401120 a.out`main at small.c:8:3
5 int main() {
6 int a = 0;
7 foo (&a);
-> 8 return 0;
9 }
Process 3563 launched: '/home/yibiao/Debugger/a.out' (x86_64)
(lldb) p a
(int) $0 = 0</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>