Home | History | Annotate | Download | only in Mips
      1 # RUN: llc -run-pass=livedebugvalues %s -o - | FileCheck %s
      2 #
      3 # This test tests tracking variables value transferring from one register to another.
      4 # This example is altered additionally in order to test transferring from one float register
      5 # to another. The altered instructions are labeled below.
      6 #
      7 # CHECK: ![[ARG1:.*]] = !DILocalVariable(name: "arg1"
      8 # CHECK: ![[ARG2:.*]] = !DILocalVariable(name: "arg2"
      9 # CHECK: DBG_VALUE debug-use $s0_64, debug-use $noreg, ![[ARG2]], !DIExpression(), debug-location
     10 # CHECK: $s1_64 = OR64 killed $s0_64, $zero_64, debug-location
     11 # CHECK-NEXT: DBG_VALUE debug-use $s1_64, debug-use $noreg, ![[ARG2]], !DIExpression(), debug-location
     12 # CHECK: DBG_VALUE debug-use $f24, debug-use $noreg, ![[ARG1]], !DIExpression(), debug-location
     13 # CHECK: $f26 = FMOV_S killed $f24, debug-location
     14 # CHECK-NEXT: DBG_VALUE debug-use $f26, debug-use $noreg, ![[ARG1]], !DIExpression(), debug-location
     15 
     16 --- |
     17   ; ModuleID = 'live-debug-values-reg-copy.ll'
     18   source_filename = "live-debug-values-reg-copy.c"
     19   target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
     20   target triple = "mips64-octeon-linux"
     21 
     22   define float @foo(float %arg1, i32 signext %arg2) local_unnamed_addr !dbg !8 {
     23   entry:
     24     call void @llvm.dbg.value(metadata float %arg1, metadata !14, metadata !DIExpression()), !dbg !19
     25     call void @llvm.dbg.value(metadata i32 %arg2, metadata !15, metadata !DIExpression()), !dbg !19
     26     %conv = fpext float %arg1 to double, !dbg !19
     27     %cmp = fcmp ogt double %conv, 1.012310e+01, !dbg !19
     28     br i1 %cmp, label %if.then, label %if.else, !dbg !19
     29 
     30   if.then:                                          ; preds = %entry
     31     %call = tail call float @externFunc(float %arg1), !dbg !19
     32     %call5 = tail call i32 @externFunc3(i32 signext %arg2), !dbg !19
     33     %conv6 = sitofp i32 %call5 to float, !dbg !19
     34     %add7 = fadd float %conv6, 0x3FF522D0E0000000, !dbg !19
     35     br label %if.end, !dbg !19
     36 
     37   if.else:                                          ; preds = %entry
     38     %add8 = fadd float %arg1, 1.000000e+01, !dbg !19
     39     call void @llvm.dbg.value(metadata float %add8, metadata !14, metadata !DIExpression()), !dbg !19
     40     %call9 = tail call float @externFunc2(float %add8), !dbg !19
     41     %call10 = tail call i32 @externFunc4(i32 signext %arg2), !dbg !19
     42     %conv11 = sitofp i32 %call10 to float, !dbg !19
     43     %add12 = fadd float %call9, %conv11, !dbg !19
     44     %call14 = tail call float @externFunc(float %add8), !dbg !19
     45     br label %if.end
     46 
     47   if.end:                                           ; preds = %if.else, %if.then
     48     %local.0 = phi float [ %add7, %if.then ], [ %add12, %if.else ]
     49     ret float %local.0, !dbg !19
     50   }
     51 
     52   declare float @externFunc(float) local_unnamed_addr
     53 
     54   declare i32 @externFunc3(i32 signext) local_unnamed_addr
     55 
     56   declare float @externFunc2(float) local_unnamed_addr
     57 
     58   declare i32 @externFunc4(i32 signext) local_unnamed_addr
     59 
     60   ; Function Attrs: nounwind readnone speculatable
     61   declare void @llvm.dbg.value(metadata, metadata, metadata) #0
     62 
     63   ; Function Attrs: nounwind
     64   declare void @llvm.stackprotector(i8*, i8**) #1
     65 
     66   attributes #0 = { nounwind readnone speculatable }
     67   attributes #1 = { nounwind }
     68 
     69   !llvm.dbg.cu = !{!0}
     70   !llvm.module.flags = !{!3, !4, !5, !6}
     71   !llvm.ident = !{!7}
     72 
     73   !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
     74   !1 = !DIFile(filename: "live-debug-values-reg-copy.c", directory: "/")
     75   !2 = !{}
     76   !3 = !{i32 2, !"Dwarf Version", i32 4}
     77   !4 = !{i32 2, !"Debug Info Version", i32 3}
     78   !5 = !{i32 1, !"wchar_size", i32 4}
     79   !6 = !{i32 7, !"PIC Level", i32 2}
     80   !7 = !{!"clang version 7.0.0 "}
     81   !8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !9, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !13)
     82   !9 = !DISubroutineType(types: !10)
     83   !10 = !{!11, !11, !12}
     84   !11 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
     85   !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
     86   !13 = !{!14, !15}
     87   !14 = !DILocalVariable(name: "arg1", arg: 1, scope: !8, file: !1, line: 6, type: !11)
     88   !15 = !DILocalVariable(name: "arg2", arg: 2, scope: !8, file: !1, line: 6, type: !12)
     89   !19 = !DILocation(line: 6, column: 17, scope: !8)
     90 
     91 ...
     92 ---
     93 name:            foo
     94 alignment:       3
     95 exposesReturnsTwice: false
     96 legalized:       false
     97 regBankSelected: false
     98 selected:        false
     99 tracksRegLiveness: false
    100 registers:
    101 liveins:
    102   - { reg: '$f12', virtual-reg: '' }
    103   - { reg: '$a1_64', virtual-reg: '' }
    104 frameInfo:
    105   isFrameAddressTaken: false
    106   isReturnAddressTaken: false
    107   hasStackMap:     false
    108   hasPatchPoint:   false
    109   stackSize:       32
    110   offsetAdjustment: 0
    111   maxAlignment:    8
    112   adjustsStack:    true
    113   hasCalls:        true
    114   stackProtector:  ''
    115   maxCallFrameSize: 0
    116   hasOpaqueSPAdjustment: false
    117   hasVAStart:      false
    118   hasMustTailInVarArgFunc: false
    119   savePoint:       ''
    120   restorePoint:    ''
    121 fixedStack:
    122 stack:
    123   - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
    124       stack-id: 0, callee-saved-register: '$d25_64', callee-saved-restored: true,
    125       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
    126   - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
    127       stack-id: 0, callee-saved-register: '$d24_64', callee-saved-restored: true,
    128       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
    129   - { id: 2, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8,
    130       stack-id: 0, callee-saved-register: '$ra_64', callee-saved-restored: true,
    131       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
    132   - { id: 3, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8,
    133       stack-id: 0, callee-saved-register: '$s0_64', callee-saved-restored: true,
    134       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
    135 constants:
    136   - id:              0
    137     value:           'double 1.012310e+01'
    138     alignment:       8
    139     isTargetSpecific: false
    140   - id:              1
    141     value:           'float 1.000000e+01'
    142     alignment:       4
    143     isTargetSpecific: false
    144   - id:              2
    145     value:           float 0x3FF522D0E0000000
    146     alignment:       4
    147     isTargetSpecific: false
    148 body:             |
    149   bb.0.entry:
    150     successors: %bb.1(0x40000000), %bb.2(0x40000000)
    151 
    152     $sp_64 = DADDiu $sp_64, -32
    153     CFI_INSTRUCTION def_cfa_offset 32
    154     SDC164 killed $d25_64, $sp_64, 24 :: (store 8 into %stack.0)
    155     SDC164 killed $d24_64, $sp_64, 16 :: (store 8 into %stack.1)
    156     SD killed $ra_64, $sp_64, 8 :: (store 8 into %stack.2)
    157     SD killed $s0_64, $sp_64, 0 :: (store 8 into %stack.3)
    158     CFI_INSTRUCTION offset $d26_64, -8
    159     CFI_INSTRUCTION offset $d25_64, -4
    160     CFI_INSTRUCTION offset $d25_64, -16
    161     CFI_INSTRUCTION offset $d24_64, -12
    162     CFI_INSTRUCTION offset $ra_64, -24
    163     CFI_INSTRUCTION offset $s0_64, -32
    164     DBG_VALUE debug-use $f12, debug-use $noreg, !14, !DIExpression(), debug-location !19
    165     DBG_VALUE debug-use $a1_64, debug-use $noreg, !15, !DIExpression(), debug-location !19
    166     DBG_VALUE debug-use $s0, debug-use $noreg, !15, !DIExpression(), debug-location !19
    167     DBG_VALUE debug-use $s0_64, debug-use $noreg, !15, !DIExpression(), debug-location !19
    168     DBG_VALUE debug-use $f12, debug-use $noreg, !14, !DIExpression(), debug-location !19
    169     renamable $d0_64 = CVT_D64_S renamable $f12, debug-location !19
    170     renamable $at_64 = LUi64 target-flags(mips-highest) %const.0
    171     renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-higher) %const.0
    172     renamable $at_64 = DSLL killed renamable $at_64, 16
    173     renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-abs-hi) %const.0
    174     renamable $at_64 = DSLL killed renamable $at_64, 16
    175     renamable $d1_64 = LDC164 killed renamable $at_64, target-flags(mips-abs-lo) %const.0, debug-location !19 :: (load 8 from constant-pool)
    176     FCMP_D64 killed renamable $d0_64, killed renamable $d1_64, 7, implicit-def $fcc0, debug-location !19
    177     BC1T killed $fcc0, %bb.2, implicit-def $at, debug-location !19 {
    178       $s0_64 = OR64 $a1_64, $zero_64
    179     }
    180 
    181   bb.1.if.then:
    182     successors: %bb.3(0x80000000)
    183 
    184     JAL @externFunc, csr_n64, implicit-def dead $ra, implicit $f12, implicit-def $sp, implicit-def dead $f0, debug-location !19 {
    185       NOP debug-location !19
    186     }
    187     JAL @externFunc3, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit-def $sp, implicit-def $v0, debug-location !19 {
    188       renamable $a0_64 = SLL64_32 renamable $s0, implicit $s0_64, debug-location !19
    189     }
    190     $f0 = MTC1 killed $v0, debug-location !19
    191     $f0 = CVT_S_W killed $f0, debug-location !19
    192     ; This instruction is inserted additionally in order to test moving from one register to another
    193     $s1_64 = OR64 killed $s0_64, $zero_64, debug-location !19
    194     renamable $at_64 = LUi64 target-flags(mips-highest) %const.2
    195     renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-higher) %const.2
    196     renamable $at_64 = DSLL killed renamable $at_64, 16
    197     renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-abs-hi) %const.2
    198     renamable $at_64 = DSLL killed renamable $at_64, 16
    199     renamable $f1 = LWC1 killed renamable $at_64, target-flags(mips-abs-lo) %const.2, debug-location !19 :: (load 4 from constant-pool)
    200     J %bb.3, implicit-def dead $at, debug-location !19 {
    201       renamable $f0 = FADD_S killed renamable $f0, killed renamable $f1, debug-location !19
    202     }
    203 
    204   bb.2.if.else:
    205     successors: %bb.3(0x80000000)
    206 
    207     renamable $at_64 = LUi64 target-flags(mips-highest) %const.1
    208     renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-higher) %const.1
    209     renamable $at_64 = DSLL killed renamable $at_64, 16
    210     renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-abs-hi) %const.1
    211     renamable $at_64 = DSLL killed renamable $at_64, 16
    212     renamable $f0 = LWC1 killed renamable $at_64, target-flags(mips-abs-lo) %const.1, debug-location !19 :: (load 4 from constant-pool)
    213     renamable $f24 = FADD_S killed renamable $f12, killed renamable $f0, debug-location !19
    214     DBG_VALUE debug-use $f24, debug-use $noreg, !14, !DIExpression(), debug-location !19
    215     JAL @externFunc2, csr_n64, implicit-def dead $ra, implicit $f12, implicit-def $sp, implicit-def $f0, debug-location !19 {
    216       $f12 = FMOV_S $f24, debug-location !19
    217     }
    218     $f25 = FMOV_S $f0, debug-location !19
    219     JAL @externFunc4, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit-def $sp, implicit-def $v0, debug-location !19 {
    220       renamable $a0_64 = SLL64_32 renamable $s0, implicit killed $s0_64, debug-location !19
    221     }
    222     $s0 = OR $v0, $zero, debug-location !19
    223     JAL @externFunc, csr_n64, implicit-def dead $ra, implicit $f12, implicit-def $sp, implicit-def dead $f0, debug-location !19 {
    224       $f12 = FMOV_S $f24, debug-location !19
    225     }
    226     $f0 = MTC1 killed $s0, debug-location !19
    227     $f0 = CVT_S_W killed $f0, debug-location !19
    228     renamable $f0 = FADD_S renamable $f25, killed renamable $f0, debug-location !19
    229     ; This instruction is inserted additionally in order to test moving variable's value from one float register to another.
    230     $f26 = FMOV_S killed $f24, debug-location !19
    231 
    232   bb.3.if.end:
    233     $s0_64 = LD $sp_64, 0, debug-location !19 :: (load 8 from %stack.3)
    234     $ra_64 = LD $sp_64, 8, debug-location !19 :: (load 8 from %stack.2)
    235     $d24_64 = LDC164 $sp_64, 16, debug-location !19 :: (load 8 from %stack.1)
    236     $d25_64 = LDC164 $sp_64, 24, debug-location !19 :: (load 8 from %stack.0)
    237     PseudoReturn64 undef $ra_64, implicit $f0, debug-location !19 {
    238       $sp_64 = DADDiu $sp_64, 32
    239     }
    240 
    241 ...
    242