[llvm-bugs] [Bug 34788] New: Faulty inserted DBG_VALUE by LiveDebugVariables when the DBG_VALUE is last use in virtual register live range

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 29 23:24:31 PDT 2017


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

            Bug ID: 34788
           Summary: Faulty inserted DBG_VALUE by LiveDebugVariables when
                    the DBG_VALUE is last use in virtual register live
                    range
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: karl-johan.karlsson at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19214
  --> https://bugs.llvm.org/attachment.cgi?id=19214&action=edit
llc -start-before=greedy -stop-after=livedebugvars foo.mir -o -

Consider the following mir as input to greedy:

  bb.0.entry:
    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead %rsp, implicit-def dead
%eflags, implicit %rsp, debug-location !14
    dead %eax = MOV32r0 implicit-def dead %eflags, implicit-def %al,
debug-location !14
    CALL64pcrel32 @getval, csr_64, implicit %rsp, implicit killed %al,
implicit-def %rsp, implicit-def %eax, debug-location !14
    ADJCALLSTACKUP64 0, 0, implicit-def dead %rsp, implicit-def dead %eflags,
implicit %rsp, debug-location !14
    %2 = COPY killed %eax, debug-location !14
    DBG_VALUE debug-use %2, debug-use _, !11, !DIExpression(), debug-location
!15
    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead %rsp, implicit-def dead
%eflags, implicit %rsp, debug-location !16
    dead %eax = MOV32r0 implicit-def dead %eflags, implicit-def %al,
debug-location !16
    CALL64pcrel32 @getval, csr_64, implicit %rsp, implicit killed %al,
implicit-def %rsp, implicit-def %eax, debug-location !16
    ADJCALLSTACKUP64 0, 0, implicit-def dead %rsp, implicit-def dead %eflags,
implicit %rsp, debug-location !16
    %3 = COPY killed %eax, debug-location !16
    DBG_VALUE debug-use %3, debug-use _, !13, !DIExpression(), debug-location
!17
    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead %rsp, implicit-def dead
%eflags, implicit %rsp, debug-location !18
    %edi = COPY %2, debug-location !18
    %esi = COPY %3, debug-location !18
    CALL64pcrel32 @usevals, csr_64, implicit %rsp, implicit killed %edi,
implicit killed %esi, implicit-def %rsp, debug-location !18
    DBG_VALUE debug-use %3, debug-use _, !11, !DIExpression(), debug-location
!15
    ADJCALLSTACKUP64 0, 0, implicit-def dead %rsp, implicit-def dead %eflags,
implicit %rsp, debug-location !18
    RET 0, debug-location !19


After the livedebugvariables pass have reinserted DBG_VALUEs (after greedy) it
look like this:

  bb.0.entry:
    liveins: %rbx

    frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp,
debug-location !14
    CFI_INSTRUCTION def_cfa_offset 16
    CFI_INSTRUCTION offset %rbx, -16
    dead %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags,
implicit-def %al, debug-location !14
    CALL64pcrel32 @getval, csr_64, implicit %rsp, implicit %al, implicit-def
%rsp, implicit-def %eax, debug-location !14
    %ebx = MOV32rr %eax, debug-location !14
    DBG_VALUE debug-use %ebx, debug-use _, !11, !DIExpression(), debug-location
!15
    dead %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags,
implicit-def %al, debug-location !16
    CALL64pcrel32 @getval, csr_64, implicit %rsp, implicit %al, implicit-def
%rsp, implicit-def %eax, debug-location !16
    DBG_VALUE debug-use %eax, debug-use _, !13, !DIExpression(), debug-location
!17
    %edi = MOV32rr killed %ebx, debug-location !18
    %esi = MOV32rr killed %eax, debug-location !18
    CALL64pcrel32 @usevals, csr_64, implicit %rsp, implicit killed %edi,
implicit killed %esi, implicit-def %rsp, debug-location !18
    DBG_VALUE debug-use %eax, debug-use _, !11, !DIExpression(), debug-location
!15
    %rbx = POP64r implicit-def %rsp, implicit %rsp, debug-location !19
    RETQ debug-location !19

The last DBG_VALUE is wrong:

DBG_VALUE debug-use %eax, debug-use _, !11, !DIExpression(), debug-location !15

The value in EAX do not necessarily contain any value connected to the variable
the DBG_VALUE is suppose to describe as the range ended before the call to
usevals. The register allocator might have reused EAX for another value.

-- 
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/20170930/e099f8ba/attachment.html>


More information about the llvm-bugs mailing list