xref: /llvm-project/llvm/test/DebugInfo/MIR/Mips/live-debug-values-reg-copy.mir (revision 92b33822e989884d29465d34769b07d78aeb1a84)
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 $s0_64, $noreg, ![[ARG2]], !DIExpression(), debug-location
10# CHECK: $s1_64 = OR64 killed $s0_64, $zero_64, debug-location
11# CHECK-NEXT: DBG_VALUE $s1_64, $noreg, ![[ARG2]], !DIExpression(), debug-location
12# CHECK: DBG_VALUE $f24, $noreg, ![[ARG1]], !DIExpression(), debug-location
13# CHECK: $f26 = FMOV_S killed $f24, debug-location
14# CHECK-NEXT: DBG_VALUE $f26, $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(ptr, ptr) #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---
93name:            foo
94alignment:       8
95exposesReturnsTwice: false
96legalized:       false
97regBankSelected: false
98selected:        false
99tracksRegLiveness: false
100registers:
101liveins:
102  - { reg: '$f12', virtual-reg: '' }
103  - { reg: '$a1_64', virtual-reg: '' }
104frameInfo:
105  isFrameAddressTaken: false
106  isReturnAddressTaken: false
107  hasStackMap:     false
108  hasPatchPoint:   false
109  stackSize:       48
110  offsetAdjustment: 0
111  maxAlignment:    8
112  adjustsStack:    true
113  hasCalls:        true
114  stackProtector:  ''
115  maxCallFrameSize: 0
116  cvBytesOfCalleeSavedRegisters: 0
117  hasOpaqueSPAdjustment: false
118  hasVAStart:      false
119  hasMustTailInVarArgFunc: false
120  localFrameSize:  0
121  savePoint:       ''
122  restorePoint:    ''
123fixedStack:      []
124stack:
125  - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
126      stack-id: default, callee-saved-register: '$d26_64', callee-saved-restored: true,
127      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
128  - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
129      stack-id: default, callee-saved-register: '$d25_64', callee-saved-restored: true,
130      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
131  - { id: 2, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8,
132      stack-id: default, callee-saved-register: '$d24_64', callee-saved-restored: true,
133      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
134  - { id: 3, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8,
135      stack-id: default, callee-saved-register: '$ra_64', callee-saved-restored: true,
136      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
137  - { id: 4, name: '', type: spill-slot, offset: -40, size: 8, alignment: 8,
138      stack-id: default, callee-saved-register: '$s1_64', callee-saved-restored: true,
139      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
140  - { id: 5, name: '', type: spill-slot, offset: -48, size: 8, alignment: 8,
141      stack-id: default, callee-saved-register: '$s0_64', callee-saved-restored: true,
142      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
143callSites:       []
144constants:
145  - id:              0
146    value:           'double 1.012310e+01'
147    alignment:       8
148    isTargetSpecific: false
149  - id:              1
150    value:           'float 1.000000e+01'
151    alignment:       4
152    isTargetSpecific: false
153  - id:              2
154    value:           float 0x3FF522D0E0000000
155    alignment:       4
156    isTargetSpecific: false
157body:             |
158  bb.0.entry:
159    successors: %bb.1(0x40000000), %bb.2(0x40000000)
160    liveins: $f12, $a1_64, $s1_64, $f26, $d26_64, $d25_64, $d24_64, $ra_64, $s1_64, $s0_64
161
162    DBG_VALUE $f12, $noreg, !14, !DIExpression(), debug-location !19
163    DBG_VALUE $a1_64, $noreg, !15, !DIExpression(), debug-location !19
164    $sp_64 = DADDiu $sp_64, -48
165    CFI_INSTRUCTION def_cfa_offset 48
166    SDC164 killed $d26_64, $sp_64, 40 :: (store (s64) into %stack.0)
167    SDC164 killed $d25_64, $sp_64, 32 :: (store (s64) into %stack.1)
168    SDC164 killed $d24_64, $sp_64, 24 :: (store (s64) into %stack.2)
169    SD killed $ra_64, $sp_64, 16 :: (store (s64) into %stack.3)
170    SD killed $s1_64, $sp_64, 8 :: (store (s64) into %stack.4)
171    SD killed $s0_64, $sp_64, 0 :: (store (s64) into %stack.5)
172    CFI_INSTRUCTION offset $d27_64, -8
173    CFI_INSTRUCTION offset $d26_64, -4
174    CFI_INSTRUCTION offset $d26_64, -16
175    CFI_INSTRUCTION offset $d25_64, -12
176    CFI_INSTRUCTION offset $d25_64, -24
177    CFI_INSTRUCTION offset $d24_64, -20
178    CFI_INSTRUCTION offset $ra_64, -32
179    CFI_INSTRUCTION offset $s1_64, -40
180    CFI_INSTRUCTION offset $s0_64, -48
181    renamable $s0_64 = COPY $a1_64
182    DBG_VALUE $s0, $noreg, !15, !DIExpression(), debug-location !19
183    DBG_VALUE $s0_64, $noreg, !15, !DIExpression(), debug-location !19
184    DBG_VALUE $f12, $noreg, !14, !DIExpression(), debug-location !19
185    renamable $d0_64 = CVT_D64_S renamable $f12, debug-location !19
186    renamable $at_64 = LUi64 target-flags(mips-highest) %const.0
187    renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-higher) %const.0
188    renamable $at_64 = DSLL killed renamable $at_64, 16
189    renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-abs-hi) %const.0
190    renamable $at_64 = DSLL killed renamable $at_64, 16
191    renamable $d1_64 = LDC164 killed renamable $at_64, target-flags(mips-abs-lo) %const.0 :: (load (s64) from constant-pool)
192    FCMP_D64 killed renamable $d0_64, killed renamable $d1_64, 7, implicit-def $fcc0, debug-location !19
193    BC1T killed $fcc0, %bb.2, implicit-def dead $at, debug-location !19
194    J %bb.1, implicit-def dead $at, debug-location !19
195
196  bb.1.if.then:
197    successors: %bb.3(0x80000000)
198    liveins: $f12, $s0_64
199
200    JAL @externFunc, csr_n64, implicit-def dead $ra, implicit $f12, implicit-def $sp, implicit-def dead $f0, debug-location !19
201    renamable $a0_64 = SLL64_32 renamable $s0, implicit $s0_64, debug-location !19
202    JAL @externFunc3, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit-def $sp, implicit-def $v0, debug-location !19
203    renamable $f0 = PseudoCVT_S_W killed renamable $v0, debug-location !19
204    ; This instruction is inserted additionally in order to test moving from one register to another
205    $s1_64 = OR64 killed $s0_64, $zero_64, debug-location !19
206    renamable $at_64 = LUi64 target-flags(mips-highest) %const.2
207    renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-higher) %const.2
208    renamable $at_64 = DSLL killed renamable $at_64, 16
209    renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-abs-hi) %const.2
210    renamable $at_64 = DSLL killed renamable $at_64, 16
211    renamable $f1 = LWC1 killed renamable $at_64, target-flags(mips-abs-lo) %const.2 :: (load (s32) from constant-pool)
212    renamable $f0 = FADD_S killed renamable $f0, killed renamable $f1, debug-location !19
213    J %bb.3, implicit-def dead $at, debug-location !19
214
215  bb.2.if.else:
216    successors: %bb.3(0x80000000)
217    liveins: $f12, $s0_64
218
219    renamable $at_64 = LUi64 target-flags(mips-highest) %const.1
220    renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-higher) %const.1
221    renamable $at_64 = DSLL killed renamable $at_64, 16
222    renamable $at_64 = DADDiu killed renamable $at_64, target-flags(mips-abs-hi) %const.1
223    renamable $at_64 = DSLL killed renamable $at_64, 16
224    renamable $f0 = LWC1 killed renamable $at_64, target-flags(mips-abs-lo) %const.1 :: (load (s32) from constant-pool)
225    renamable $f24 = FADD_S killed renamable $f12, killed renamable $f0, debug-location !19
226    DBG_VALUE $f24, $noreg, !14, !DIExpression(), debug-location !19
227    $f12 = COPY renamable $f24, debug-location !19
228    JAL @externFunc2, csr_n64, implicit-def dead $ra, implicit $f12, implicit-def $sp, implicit-def $f0, debug-location !19
229    renamable $f25 = COPY $f0, debug-location !19
230    renamable $a0_64 = SLL64_32 renamable $s0, implicit killed $s0_64, debug-location !19
231    JAL @externFunc4, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit-def $sp, implicit-def $v0, debug-location !19
232    renamable $s0 = COPY $v0, debug-location !19
233    $f12 = COPY renamable $f24, debug-location !19
234    JAL @externFunc, csr_n64, implicit-def dead $ra, implicit $f12, implicit-def $sp, implicit-def dead $f0, debug-location !19
235    renamable $f0 = PseudoCVT_S_W killed renamable $s0, debug-location !19
236    renamable $f0 = FADD_S killed renamable $f25, killed renamable $f0, debug-location !19
237    ; This instruction is inserted additionally in order to test moving variable's value from one float register to another.
238    $f26 = FMOV_S killed $f24, debug-location !19
239
240  bb.3.if.end:
241    liveins: $f0
242
243    $s0_64 = LD $sp_64, 0, debug-location !19 :: (load (s64) from %stack.5)
244    $s1_64 = LD $sp_64, 8, debug-location !19 :: (load (s64) from %stack.4)
245    $ra_64 = LD $sp_64, 16, debug-location !19 :: (load (s64) from %stack.3)
246    $d24_64 = LDC164 $sp_64, 24, debug-location !19 :: (load (s64) from %stack.2)
247    $d25_64 = LDC164 $sp_64, 32, debug-location !19 :: (load (s64) from %stack.1)
248    $d26_64 = LDC164 $sp_64, 40, debug-location !19 :: (load (s64) from %stack.0)
249    $sp_64 = DADDiu $sp_64, 48
250    RetRA implicit $f0, debug-location !19
251
252...
253