<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] Too much indirection added to stack pointer's variable location"
href="https://bugs.llvm.org/show_bug.cgi?id=41675">41675</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[DebugInfo@O2] Too much indirection added to stack pointer's variable location
</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>Keywords</th>
<td>wrong-debug
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</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>aprantl@apple.com, chackz0x12@gmail.com, greg.bedwell@sony.com, llvm-bugs@lists.llvm.org, orlando.hyams@sony.com, paul.robinson@am.sony.com, stephen.tozer@sony.com
</td>
</tr>
<tr>
<th>Blocks</th>
<td>38768
</td>
</tr></table>
<p>
<div>
<pre>Spinning out of <a class="bz_bug_link
bz_status_CONFIRMED "
title="CONFIRMED - Clang-trunk Generates Wrong Debug values with -O1"
href="show_bug.cgi?id=41534">bug 41534</a>, where Yuanbo has the following code:
--------8<--------
$ cat abc.c
int a;
int *b;
int main() {
int l_1081 = 1834104526;
int *c = &l_1081;
b = c;
*b = a = 9;
optimize_me_not();
}
$ cat outer.c
optimize_me_not() {}
-------->8--------
Compiling with clang/llvm r358073 and options "-O2 -g", printing the "c"
variable on any line of the program yields a pointer that doesn't point at the
stack. Examining the location:
--------8<--------
DW_AT_location (0x00000000
[0x0000000000400486, 0x00000000004004a9): DW_OP_breg7 RSP+4)
DW_AT_name ("c")
-------->8--------
Shows that the location of 'c' has grown one too many levels of indirection:
the variable should be the _value_ of RSP+4 (i.e., a pointer at the stack), not
the memory data that the expression points at.
Examining the debug intrinsics for the "c" variable as they change over time,
before isel we have:
dbg.value(metadata i32* %l_1081, metadata !19, metadata !DIExpression())
Between isel and prologepilog, where frame indexes are finalised, we get:
DBG_VALUE %stack.0.l_1081, $noreg, !19, !DIExpression(), [...]
And from prologepilog to object emission we get:
DBG_VALUE $rsp, $noreg, !19, !DIExpression(DW_OP_plus_uconst, 4), [...]
My current belief is that switching the DIExpression from being empty to
non-empty also implicitly transforms the DBG_VALUE into being a memory location
description rather than a register location description. However, I'm
unfamiliar with how the DWARF backend treats these things, I'm about 70%
confident.
Adding a DW_OP_stack_value to non-indirect DBG_VALUEs when frameindexes are
rewritten fixes this example but makes a bunch of tests break, in seemly
significant ways. I haven't dug any further, it might be that DW_OP_stack_value
is only needed when the DIExpression is initially empty?</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>