<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 debug information with stack slot sharing"
href="https://bugs.llvm.org/show_bug.cgi?id=50072">50072</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect debug information with stack slot sharing
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>markus.lavin@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Consider
---
void consume(int *in);
int *getptr();
static inline void force_spill() {
__asm volatile(""
:
:
: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
"r10", "r11", "r12", "r14", "r15");
}
void spill() {
#pragma nounroll
for (int i = 0; i < 16; ++i) {
int *p = getptr();
force_spill();
consume(p);
int *q = getptr();
force_spill();
consume(q);
}
}
---
compiling with
$ clang -g -O3 spill-arm.c --target=arm-linux-gnu -mfloat-abi=soft -S
Now variables 'p' and 'q' will be spilled to stack slots between the calls to
'getptr' and 'consume'. Since these two variables are not live at the same time
the stack slots can be shared and the 'stack-slot-coloring' pass merges them
into the same stack slot. This is all fine but when looking at the final debug
info in 'spill-arm.s' we can see that the location range for 'p' overlaps that
of 'q'. This is clearly incorrect as it will result in the debugger showing the
value of 'q' for 'p' when 'q' is live.
.Ldebug_loc0: // for 'p'
.long .Ltmp3-.Lfunc_begin0
.long .Ltmp12-.Lfunc_begin0
.Ldebug_loc1: // for 'q'
.long .Ltmp7-.Lfunc_begin0
.long .Ltmp12-.Lfunc_begin0
The expected behavior would have been for the range for 'p' to end when the
range for 'q' begins (so that the debugger would have shown '<optimized-out>'
for 'p' when 'q' is live).
To me it seems that this could be addressed in 'stack-slot-coloring' by
inserting a 'DBG_VALUE $noreg, ..., "p"' at the point where 'q' is merged into
the slot of 'p'. But I am not really sure of the semantics of DBG_VALUE at this
point in the pipeline so perhaps it should be addressed elsewhere
(DbgEntityHistoryCalculator.cpp?).</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>