<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 - Debug fragment offsets are emitted in the wrong order for symbol locations"
href="https://bugs.llvm.org/show_bug.cgi?id=36085">36085</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Debug fragment offsets are emitted in the wrong order for symbol locations
</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>Severity</th>
<td>enhancement
</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>david.stenberg@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19747" name="attach_19747" title="llc input">attachment 19747</a> <a href="attachment.cgi?id=19747&action=edit" title="llc input">[details]</a></span>
llc input
LLVM commit used: r323411.
When compiling foo.c:
struct {
long foo;
void *bar;
long baz;
void *qux;
} static var = { .bar = (void *)0x1234, .qux = (void *)0x5678 };
void *ptr;
int main() {
if (var.foo == 0)
var.bar = var.qux = ptr;
return 0;
}
using:
clang -march=x86-64 -O0 -g2 -S -emit-llvm foo.c -o foo.ll
opt -S -globalopt foo.ll -o foo.opt.ll
llc -O0 foo.opt.ll -filetype=obj -o foo.obj
the following debug info is emitted for the SRA'd struct variable, in which
the first and third fields have been optimized out:
<1><40>: Abbrev Number: 4 (DW_TAG_variable)
<41> DW_AT_name : (indirect string, offset: 0x10f): var
<45> DW_AT_type : <0x66>
<49> DW_AT_decl_file : 1
<4a> DW_AT_decl_line : 6
<4b> DW_AT_location : 26 byte block: 3 0 0 0 0 0 0 0 0 93 8 93 8 3 8
0 0 0 0 0 0 0 93 8 93 8 (DW_OP_addr: 0; DW_OP_piece: 8; DW_OP_piece: 8;
DW_OP_addr: 8; DW_OP_piece: 8; DW_OP_piece: 8)
As seen, the DW_OP_addr operations for the second and fourth field are emitted
before the pieces used as offsets for the optimized-out first and third
variable, leading the operations to be associated with wrong parts of the
variable.
This can be further seen by printing the variable in gdb:
echo "print /x var" | gdb a.out | grep '\$1'
(gdb) $1 = {foo = 0x1234, bar = <optimized out>, baz = 0x5678, qux = <optimized
out>}</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>