llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Missing DW_OP_LLVM_fragment for field of global transformed to bool

Open efriedma-quic opened this issue 9 years ago • 2 comments

Bugzilla Link 34921
Version unspecified
OS Windows NT
CC @adrian-prantl,@dwblaikie,@rnk

Extended Description

Testcase (compile with clang -O2 -g -S -emit-llvm):

struct X { int a; int b; };
static struct X x;
int f() { return x.a; }
void g() { x.a = 10; }
int h() { return x.b += 1; }

https://reviews.llvm.org/D35994 added debug info for x.a... but it isn't really complete in this case, because it's missing the offset in the struct.

efriedma-quic avatar Oct 12 '17 00:10 efriedma-quic

@llvm/issue-subscribers-debuginfo

Author: Eli Friedman (efriedma-quic)

| | | | --- | --- | | Bugzilla Link | [34921](https://llvm.org/bz34921) | | Version | unspecified | | OS | Windows NT | | CC | @adrian-prantl,@dwblaikie,@rnk |

Extended Description

Testcase (compile with clang -O2 -g -S -emit-llvm):

struct X { int a; int b; };
static struct X x;
int f() { return x.a; }
void g() { x.a = 10; }
int h() { return x.b += 1; }

https://reviews.llvm.org/D35994 added debug info for x.a... but it isn't really complete in this case, because it's missing the offset in the struct.

llvmbot avatar Apr 14 '24 11:04 llvmbot

This seems to have been since fixed: https://godbolt.org/z/x735n5xPv

@x (.0) = internal unnamed_addr global i1 false, align 4, !dbg !0
@x (.1) = internal unnamed_addr global i32 0, align 4, !dbg !12
...
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression(DW_OP_deref_size, 1, DW_OP_constu, 10, DW_OP_mul, DW_OP_constu, 0, DW_OP_plus, DW_OP_stack_value, DW_OP_LLVM_fragment, 0, 32)
...
!12 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression(DW_OP_LLVM_fragment, 32, 32))
0x0000002a:   DW_TAG_variable
                DW_AT_name	("x")
                DW_AT_type	(0x00000057 "X")
                DW_AT_decl_file	("/app/example.cpp")
                DW_AT_decl_line	(2)
                DW_AT_location	(DW_OP_addr 0x4014, DW_OP_deref_size 0x1, DW_OP_lit10, DW_OP_mul, DW_OP_lit0, DW_OP_plus, DW_OP_stack_value, DW_OP_piece 0x4, DW_OP_addr 0x4018, DW_OP_piece 0x4)
                DW_AT_linkage_name	("_ZL1x")

OCHyams avatar Sep 04 '24 09:09 OCHyams