<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 - LiveDebugValues pass incorrectly handles register spill for indirect debug values"
href="https://bugs.llvm.org/show_bug.cgi?id=51704">51704</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LiveDebugValues pass incorrectly handles register spill for indirect debug values
</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>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>kosov.pavel@huawei.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>Created <span class=""><a href="attachment.cgi?id=25213" name="attach_25213" title="Archive contains build script, source files and gdb commands for reproducing this bug">attachment 25213</a> <a href="attachment.cgi?id=25213&action=edit" title="Archive contains build script, source files and gdb commands for reproducing this bug">[details]</a></span>
Archive contains build script, source files and gdb commands for reproducing
this bug
When handling register spill for indirect debug value LiveDebugValues pass
doesn't add
DW_OP_deref operator which may in some cases cause debugger to return value
address, instead
of value while machine register holding that address is spilled.
Attached file contains reproducer for this issue, which is actualy made from
one of LLVM
integration tests (DebugInfo/MIR/X86/live-debug-values-restore.mir). To
reproduce:
- compile the sample with build.sh script from the attached archive
- invoke gdb with command file: gdb -x gdb-commands.txt ldv-indir-test
You should see something like following in the output:
```
Breakpoint 2, 0x00000000002018df in j (t=274877906976) at test2.c:106
106 test2.c: No such file or directory.
1: x/3i $pc
=> 0x2018df <j+15>: mov %rdi,-0x8(%rsp)
0x2018e4 <j+20>: mov -0x8(%rsp),%rdi
0x2018e9 <j+25>: pop %rbx
(gdb) p/x t
$1 = 0x4000000020
(gdb) si
107 in test2.c
1: x/3i $pc
=> 0x2018e4 <j+20>: mov -0x8(%rsp),%rdi
0x2018e9 <j+25>: pop %rbx
0x2018ea <j+26>: pop %r12
(gdb) p/x t
$2 = 0x7fffffffd894
```
So the value of t ($1) changes to ($2) while t's address (%rdi) is spilled
to -0x8(%rsp).
If you look at DW_AT_location entries for `t` you can see why this happens:
```
DW_TAG_formal_parameter
DW_AT_location (0x00000181:
[0x00000000002018a3, 0x00000000002018b7): DW_OP_breg5 RDI+0
[0x00000000002018b7, 0x00000000002018bc): DW_OP_breg7 RSP-8
[0x00000000002018bc, 0x00000000002018ca): DW_OP_breg5 RDI+0)
DW_AT_name ("t")
```
The second location entry (RSP-8) is created without DW_OP_deref, so debugger
shows an address instead of value.</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>