<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 - Variable's value late availability and incorrect at Og"
href="https://bugs.llvm.org/show_bug.cgi?id=52238">52238</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Variable's value late availability and incorrect at Og
</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>enhancement
</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>cristianassaiante@outlook.com
</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>Variable l_5 value is not available on line 4 even if its assignment has been
done and it becomes available at line 6.
Moreover, the value of the variable seems to be wrong since lldb shows 1 but
the assignment at line 7 has not been reached yet.
>From bisect, this behavior may be caused by Branch Probability Basic Block
Placement on function (main).
$ cat a.c
volatile int a, b;
void c() {
int l_5 = 5;
for (;
b >= 0;
b --) {
l_5 = 1;
}
}
int main () {
c();
}
$ clang -v
clang version 13.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ lldb -v
lldb version 13.0.0
$ clang -g -Og -o opt a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/40/reduce/opt' (x86_64).
(lldb) b 3
Breakpoint 1: 2 locations.
(lldb) run
Process 197 launched: '/home/stepping/40/reduce/opt' (x86_64)
Process 197 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.2
frame #0: 0x00000000004004b7 opt`main [inlined] c at a.c:4:5
1 volatile int a, b;
2 void c() {
3 int l_5 = 5;
-> 4 for (;
5 b >= 0;
6 b --) {
7 l_5 = 1;
(lldb) frame var
(int) l_5 = <variable not available>
(lldb) n
Process 197 stopped
* thread #1, name = 'opt', stop reason = step over
frame #0: 0x00000000004004c0 opt`main [inlined] c at a.c:6:11
3 int l_5 = 5;
4 for (;
5 b >= 0;
-> 6 b --) {
7 l_5 = 1;
8 }
9 }
(lldb) frame var
(int) l_5 = 1</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>