[llvm-bugs] [Bug 38899] New: [DebugInfo] DBG_VALUE for spill is emitted before the spill is performed

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 10 23:25:19 PDT 2018


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

            Bug ID: 38899
           Summary: [DebugInfo] DBG_VALUE for spill is emitted before the
                    spill is performed
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: david.stenberg at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20865
  --> https://bugs.llvm.org/attachment.cgi?id=20865&action=edit
C reproducer.

Reproduced on trunk (r341822).

When compiling the attached C file using:

        clang -O3 -g foo.c -S --target=ppc64 -S -emit-llvm -o foo.ll
        llc -O3 foo.ll -o foo.mir -print-before-all -print-after-all -debug
-stop-after=virtregrewriter &> foo.log

we get a spurious DBG_VALUE emitted for the variable c after register
allocation.

Before Debug Variable Analysis:

        # *** IR Dump Before Debug Variable Analysis ***:
        # Machine code for function test: NoPHIs, TracksLiveness
        Function Live Ins: $x3 in %0, $x4 in %1

        0B      bb.0.entry:
                  liveins: $x3, $x4
                  DBG_VALUE debug-use $x3, debug-use $noreg, !"a",
!DIExpression(), debug-location !16; foo.c:8:14 line no:8
                  DBG_VALUE debug-use $x4, debug-use $noreg, !"b",
!DIExpression(), debug-location !17; foo.c:8:21 line no:8
        16B       %1:g8rc = COPY $x4
                  DBG_VALUE debug-use %1:g8rc, debug-use $noreg, !"b",
!DIExpression(), debug-location !17; foo.c:8:21 line no:8
        32B       %0:g8rc = COPY $x3
                  DBG_VALUE debug-use %0:g8rc, debug-use $noreg, !"a",
!DIExpression(), debug-location !16; foo.c:8:14 line no:8
                  DBG_VALUE debug-use %0.sub_32:g8rc, debug-use $noreg, !"a",
!DIExpression(), debug-location !16; foo.c:8:14 line no:8
                  DBG_VALUE debug-use %1.sub_32:g8rc, debug-use $noreg, !"b",
!DIExpression(), debug-location !17; foo.c:8:21 line no:8
        80B       %4:gprc = MULLW %1.sub_32:g8rc, %0.sub_32:g8rc,
debug-location !18; foo.c:9:13
                  DBG_VALUE debug-use %4:gprc, debug-use $noreg, !"c",
!DIExpression(), debug-location !19; foo.c:9:7 line no:9
        96B       INLINEASM &"" [sideeffect] [attdialect], $0:[clobber], {{{
implicit-def early-clobber of $r0-$r1 omitted }}}, !25, debug-location !20;
foo.c:2:3 @[ foo.c:10:3 ]
        112B      %5:g8rc = EXTSW_32_64 %4:gprc, debug-location !26; foo.c:11:3
        128B      $x3 = COPY %5:g8rc, debug-location !26; foo.c:11:3
        144B      BLR8 implicit $lr8, implicit $rm, implicit $x3,
debug-location !26; foo.c:11:3

        # End machine code for function test.

        ********** COMPUTING LIVE DEBUG VARIABLES: test **********
        ********** DEBUG VARIABLES **********
        !"a,8"   [0B;0e):0 [80B;80r):2 Loc0=debug-use $x3 Loc1=debug-use %0
Loc2=debug-use %0.sub_32
        !"b,8"   [0B;0e):0 [16r;32r):1 [80B;80r):2 Loc0=debug-use $x4
Loc1=debug-use %1 Loc2=debug-use %1.sub_32
        !"c,9"   [80r;112r):0 Loc0=debug-use %4

and after Virtual Register Rewriter:

        ********** EMITTING LIVE DEBUG VARIABLES **********
        !"a,8"   [0B;0e):0 [80B;80r):2 Loc0=debug-use $x3 Loc1=debug-use %0
Loc2=debug-use %0.sub_32
                [0B;0e):0 %bb.0-160B
                [64B;80r):1 %bb.0-160B
        !"b,8"   [0B;0e):0 [16r;32r):1 [80B;80r):2 Loc0=debug-use $x4
Loc1=debug-use %1 Loc2=debug-use %1.sub_32
                [0B;0e):0 %bb.0-160B
                [16r;32r):0 %bb.0-160B
                [64B;80r):1 %bb.0-160B
        !"c,9"   [80r;112r):0 Loc0=debug-use %4
                [80r;112r):0 %bb.0-160B
        # *** IR Dump After Virtual Register Rewriter ***:
        # Machine code for function test: NoPHIs, TracksLiveness, NoVRegs
        Frame Objects:
          fi#0: size=4, align=4, at location [SP]
        Function Live Ins: $x3, $x4

        bb.0.entry:
          liveins: $x3, $x4
          DBG_VALUE debug-use $x3, debug-use $noreg, !"a", !DIExpression(),
debug-location !16; foo.c:8:14 line no:8
          DBG_VALUE debug-use $r3, debug-use $noreg, !"a", !DIExpression(),
debug-location !16; foo.c:8:14 line no:8
          DBG_VALUE debug-use $x4, debug-use $noreg, !"b", !DIExpression(),
debug-location !17; foo.c:8:21 line no:8
          DBG_VALUE debug-use $x4, debug-use $noreg, !"b", !DIExpression(),
debug-location !17; foo.c:8:21 line no:8
          DBG_VALUE debug-use $r4, debug-use $noreg, !"b", !DIExpression(),
debug-location !17; foo.c:8:21 line no:8
          renamable $r3 = MULLW renamable $r4, renamable $r3, implicit killed
$x3, implicit killed $x4, debug-location !18; foo.c:9:13
          DBG_VALUE %stack.0, 0, !"c", !DIExpression(), debug-location !19;
foo.c:9:7 line no:9
          STW killed renamable $r3, 0, %stack.0 :: (store 4 into %stack.0)
          INLINEASM &"" [sideeffect] [attdialect], $0:[clobber], {{{
implicit-def early-clobber of $r0-$r1 omitted }}}, !25, debug-location !20;
foo.c:2:3 @[ foo.c:10:3 ]
          renamable $r3 = LWZ 0, %stack.0, debug-location !26 :: (load 4 from
%stack.0); foo.c:11:3
          renamable $x3 = EXTSW_32_64 killed renamable $r3, debug-location !26;
foo.c:11:3
          BLR8 implicit $lr8, implicit $rm, implicit $x3, debug-location !26;
foo.c:11:3

As seen, a DBG_VALUE referring to the spill stack slot is emitted before the
spill is performed.

I guess that the ideal output would be a DBG_VALUE referring to $r3 after the
MULLW, and one after the spill, i.e.:

          renamable $r3 = MULLW renamable $r4, renamable $r3, implicit killed
$x3, implicit killed $x4, debug-location !18; foo.c:9:13
          DBG_VALUE debug-use $r3, debug-use $noreg, !"c", !DIExpression(),
debug-location !19; foo.c:9:7 line no:9
          STW killed renamable $r3, 0, %stack.0 :: (store 4 into %stack.0)
          DBG_VALUE %stack.0, 0, !"c", !DIExpression(), debug-location !19;
foo.c:9:7 line no:9

-- 
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/20180911/ad0fa37e/attachment.html>


More information about the llvm-bugs mailing list