[llvm-bugs] [Bug 40283] New: Incorrect location list entries are emitted when merging fragmented DBG_VALUEs with different ranges

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 10 06:25:24 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40283

            Bug ID: 40283
           Summary: Incorrect location list entries are emitted when
                    merging fragmented DBG_VALUEs with different ranges
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: david.stenberg at ericsson.com
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190110/baee056e/attachment.html>


More information about the llvm-bugs mailing list