[llvm-bugs] [Bug 44651] New: Too narrow debug location range after register coalescing

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 24 04:40:26 PST 2020


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

            Bug ID: 44651
           Summary: Too narrow debug location range after register
                    coalescing
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          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

Commit: 4e8116f4692e9b5787ba91c6b557b113aae7e244

Reproducer:

    extern void foo(int *);
    extern void bar(int *);

    int global;

    int main() {
      int *ptr = &global;
      foo(ptr);
      bar(ptr);
      return 0;
    }

Command:

    clang -O1 -g global-ptr.c

The location list for the local `ptr' variable only covers the call to bar(),
and not the one to foo():

    main:                                   # @main
    .Lfunc_begin0:
        .loc    1 6 0                   # global-ptr.c:6:0
        .cfi_startproc
    # %bb.0:                                # %entry
        pushq   %rax
        .cfi_def_cfa_offset 16
    .Ltmp0:
        .loc    1 8 3 prologue_end      # global-ptr.c:8:3
        movl    $global, %edi
        callq   foo
    .Ltmp1:
        .loc    1 9 3                   # global-ptr.c:9:3
        movl    $global, %edi
    .Ltmp2:
        #DEBUG_VALUE: main:ptr <- $rdi
        callq   bar
    .Ltmp3:
        .loc    1 10 3                  # global-ptr.c:10:3
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq

This seems to be due to something Simple Register Coalescing does:

    -# *** IR Dump Before Simple Register Coalescing ***:
    +# *** IR Dump After Simple Register Coalescing ***:
     # Machine code for function main: NoPHIs, TracksLiveness

     0B bb.0.entry:
     16B          ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp,
implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit
$ssp, debug-location !23; global-ptr.c:8:3
    -32B          %0:gr64 = MOV32ri64 @global, debug-location !23;
global-ptr.c:8:3
    -     DBG_VALUE %0:gr64, $noreg, !"ptr", !DIExpression(), debug-location
!22; global-ptr.c:0 line no:7
    -48B          $rdi = COPY %0:gr64, debug-location !23; global-ptr.c:8:3
    +48B          $rdi = MOV32ri64 @global, debug-location !23;
global-ptr.c:8:3
     64B          CALL64pcrel32 @foo, <regmask $bh $bl $bp $bph $bpl $bx $ebp
$ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh
$r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and
3 more...>, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def
$rsp, implicit-def $ssp, debug-location !23; global-ptr.c:8:3
     80B          ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def
dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp,
debug-location !23; global-ptr.c:8:3
     96B          ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp,
implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit
$ssp, debug-location !24; global-ptr.c:9:3
    -112B         $rdi = COPY %0:gr64, debug-location !24; global-ptr.c:9:3
    +112B         $rdi = MOV32ri64 @global, debug-location !24;
global-ptr.c:9:3
    +     DBG_VALUE $rdi, $noreg, !"ptr", !DIExpression(), debug-location !22;
global-ptr.c:0 line no:7
     128B         CALL64pcrel32 @bar, <regmask $bh $bl $bp $bph $bpl $bx $ebp
$ebx $hbp $hbx $rbp $rbx $r12 $r13 $r14 $r15 $r12b $r13b $r14b $r15b $r12bh
$r13bh $r14bh $r15bh $r12d $r13d $r14d $r15d $r12w $r13w $r14w $r15w $r12wh and
3 more...>, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def
$rsp, implicit-def $ssp, debug-location !24; global-ptr.c:9:3
     144B         ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def
dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp,
debug-location !24; global-ptr.c:9:3
    -160B         %1:gr32 = MOV32r0 implicit-def dead $eflags
    -176B         $eax = COPY %1:gr32, debug-location !25; global-ptr.c:10:3
    +176B         $eax = MOV32r0 implicit-def dead $eflags, debug-location !25;
global-ptr.c:10:3
     192B         RET 0, killed $eax, debug-location !25; global-ptr.c:10:3

-- 
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/20200124/86081f6d/attachment-0001.html>


More information about the llvm-bugs mailing list