<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 - [DI] LLVM loses track of induction variables at -O1 and beyond"
href="https://bugs.llvm.org/show_bug.cgi?id=35530">35530</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[DI] LLVM loses track of induction variables at -O1 and beyond
</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>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>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>davide@freebsd.org
</td>
</tr>
<tr>
<th>CC</th>
<td>aprantl@apple.com, friss@apple.com, jdevlieghere@apple.com, jingham@apple.com, jmolenda@apple.com, llvm-bugs@lists.llvm.org, vsk@apple.com
</td>
</tr></table>
<p>
<div>
<pre>Testcase:
$ cat missing.cpp
#include <atomic>
#include <limits.h>
#include <stdint.h>
int
main(void)
{
std::atomic<uint64_t> limit(0);
std::atomic<uint64_t> vr_ac(0);
uint64_t vr_index;
limit.store(UINT64_MAX, std::memory_order_seq_cst);
for (vr_index = 0; vr_index < limit; vr_index++)
vr_ac.store(vr_index, std::memory_order_seq_cst);
return vr_ac;
}
The quality of DI generates varies a bit depending on the optimization level.
-O0 -g:
(lldb) p vr_ac
(std::__1::atomic<unsigned long long>) $0 = 519251459
(lldb) p vr_index
(uint64_t) $1 = 519251460
(lldb) p limit
(std::__1::atomic<unsigned long long>) $2 = 18446744073709551615
-O1 -g:
(lldb) p vr_index
(uint64_t) $1 = 12232201402
(lldb) p vr_ac
error: Couldn't materialize: couldn't get the value of variable vr_ac: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p limit
error: Couldn't materialize: couldn't get the value of variable limit: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
-O2 -g (also -O3 -g):
(lldb) p vr_index
(uint64_t) $0 = 0
(lldb) p limit
error: Couldn't materialize: couldn't get the value of variable limit: no
location, value may have been optimized out
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p vr_ac
error: Couldn't materialize: couldn't get the value of variable vr_ac: no
location, value may have been optimized out
At -O1, it's not able to retrieve the values for vr_ac and limit (although
they're atomic and therefore not optimized out). At -O2, it's slightly worse as
the value of vr_index is wrong (always zero, no matter when I break).
I'm actually not on top-of-tree so the situation might have improved a bit, but
writing this down so I won't forget (and I'll test with a new compiler as soon
as I can).</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>