<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 - Incorrect location list entries are emitted when merging fragmented DBG_VALUEs with different ranges"
href="https://bugs.llvm.org/show_bug.cgi?id=40283">40283</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect location list entries are emitted when merging fragmented DBG_VALUEs with different ranges
</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>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>david.stenberg@ericsson.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>Tested on r350697.
When compiling the following C program:
typedef struct { int a; int b; } S;
int global;
__attribute__((noinline))
void baz(int p) {
global = p; // Side effect to keep the call.
}
__attribute__((noinline))
void bar(int p) {
baz(p + 10000);
}
int var1 = 123;
int var2 = 456;
int main() {
S s = {var1, var2};
bar(s.a);
return s.b;
}
using:
clang -O1 -g -gdwarf-4 -S foo.c
the following assembly output is emitted for main:
main: # @main
.Lfunc_begin2:
.loc 1 17 0 is_stmt 1 # foo.c:17:0
.cfi_startproc
# %bb.0: # %entry
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset %rbx, -16
.loc 1 18 10 prologue_end # foo.c:18:10
movl var1(%rip), %edi
.Ltmp3:
#DEBUG_VALUE: main:s <- [DW_OP_LLVM_fragment 0 32] $edi
.loc 1 18 16 is_stmt 0 # foo.c:18:16
movl var2(%rip), %ebx
.Ltmp4:
#DEBUG_VALUE: main:s <- [DW_OP_LLVM_fragment 32 32] $ebx
.loc 1 19 3 is_stmt 1 # foo.c:19:3
callq bar
.loc 1 20 3 # foo.c:20:3
movl %ebx, %eax
popq %rbx
.Ltmp5:
.cfi_def_cfa_offset 8
retq
As seen, a DBG_VALUE for s.a, which is described by the call-clobbered register
$edi, and a DBG_VALUE for s.b, which is described by the protected register
$ebx, is emitted. This looks fine to me. What we should expect here is for s.a
to be marked as unavailable (i.e. an empty piece) after the call to bar, and
s.b being located in $ebx. However, the location list does not look like that:
.Ldebug_loc1:
.quad .Ltmp3-.Lfunc_begin0
.quad .Ltmp4-.Lfunc_begin0
.short 3 # Loc expr size
.byte 85 # super-register DW_OP_reg5
.byte 147 # DW_OP_piece
.byte 4 # 4
.quad .Ltmp4-.Lfunc_begin0
.quad .Ltmp5-.Lfunc_begin0
.short 6 # Loc expr size
.byte 85 # super-register DW_OP_reg5
.byte 147 # DW_OP_piece
.byte 4 # 4
.byte 83 # super-register DW_OP_reg3
.byte 147 # DW_OP_piece
.byte 4 # 4
.quad 0
.quad 0
As seen, we say that s.a is still in $edi after the call, resulting in an
incorrect value being printed there.</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>