<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 - [DebugInfo@O2][Dexter] Incorrect variable valuations reported from loop"
href="https://bugs.llvm.org/show_bug.cgi?id=38779">38779</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[DebugInfo@O2][Dexter] Incorrect variable valuations reported from loop
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>Keywords</th>
<td>wrong-debug
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jeremy.morse.llvm@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>chackz0x12@gmail.com, greg.bedwell@sony.com, international.phantom@gmail.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
</td>
</tr>
<tr>
<th>Blocks</th>
<td>38768
</td>
</tr></table>
<p>
<div>
<pre>Debuggers report the loop below as having a constant-valued iterator ("i") and
wildly-changing accumulator ("sum"). Testing environment is llvm/clang @
r340912 and options "-O2 -g -fno-inline -fno-unroll-loops" for x86_64. I've
used no-funroll-loops for conciseness, this replicates if one just uses a large
loop bound too. Both lldb and gdb report the same problems.
In the loop below, the iterator "i" is reported as optimised out when stopped
on the loop-header line, or as the value one when stopped on the line that
calls "lul" for every iteration of the loop.
The "sum" variable is more exciting: when stopped on the loop header the true
value of the variable is reported, but when stopped on the line calling "lul",
a constant value of zero is reported.
My feeling here is that the instruction-range for constant initialisation of
"sum" and "i" is encroaching on the loop; as for "i" being optimised-out,
that's likely because the indvars pass makes very little effort to preserve
debug data, for which I'll open a different ticket.
-------->8--------
int
lul(int i, int other)
{
volatile int foo = i;
return foo + other;
}
int
somearray[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int
main()
{
int sum = 0;
int *ptr = somearray;
for (int i = 1; i < 11; i++, ptr++) {
sum += lul(i, *ptr);
}
return sum;
}
--------8<--------</pre>
</div>
</p>
<div id="referenced">
<hr style="border: 1px dashed #969696">
<b>Referenced Bugs:</b>
<ul>
<li>
[<a class="bz_bug_link
bz_status_NEW "
title="NEW - [meta][DebugInfo] Umbrella bug for poor debug experiences"
href="https://bugs.llvm.org/show_bug.cgi?id=38768">Bug 38768</a>] [meta][DebugInfo] Umbrella bug for poor debug experiences
</li>
</ul>
</div>
<br>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>