https://bugs.llvm.org/show_bug.cgi?id=36085
Bug ID: 36085
Summary: Debug fragment offsets are emitted in the wrong order
for symbol locations
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: david.stenb...@ericsson.com
CC: llvm-bugs@lists.llvm.org
Created attachment 19747
--> https://bugs.llvm.org/attachment.cgi?id=19747&action=edit
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>}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs