1 # RUN: llc -run-pass=livedebugvalues %s -o - | FileCheck %s
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.
7 # CHECK: ![[ARG1:.*]] = !DILocalVariable(name: "arg1"
8 # CHECK: DBG_VALUE $r4, $noreg, ![[ARG1]], !DIExpression(), debug-location
9 # CHECK: $r5 = MOVr killed $r4, 14, $noreg, $noreg, debug-location
10 # CHECK-NEXT: DBG_VALUE $r5, $noreg, ![[ARG1]], !DIExpression(), debug-location
12 ; ModuleID = 'live-debug-values-reg-copy.ll'
13 source_filename = "live-debug-values-reg-copy.c"
14 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
15 target triple = "armv4t--"
17 define dso_local arm_aapcscc i32 @foo(i32 %arg1) local_unnamed_addr !dbg !8 {
19 call void @llvm.dbg.value(metadata i32 %arg1, metadata !13, metadata !DIExpression()), !dbg !16
20 %cmp = icmp sgt i32 %arg1, 10, !dbg !16
21 br i1 %cmp, label %if.end, label %if.else, !dbg !16
23 if.else: ; preds = %entry
24 %add5 = add nsw i32 %arg1, 10, !dbg !16
25 call void @llvm.dbg.value(metadata i32 %add5, metadata !13, metadata !DIExpression()), !dbg !16
26 %call6 = tail call arm_aapcscc i32 @externFunc2(i32 %add5), !dbg !16
27 %call8 = tail call arm_aapcscc i32 @externFunc(i32 %add5), !dbg !16
28 ret i32 %call6, !dbg !16
30 if.end: ; preds = %entry
31 %call = tail call arm_aapcscc i32 @externFunc(i32 %arg1), !dbg !16
35 declare dso_local arm_aapcscc i32 @externFunc(i32) local_unnamed_addr
37 declare dso_local arm_aapcscc i32 @externFunc2(i32) local_unnamed_addr
39 ; Function Attrs: nounwind readnone speculatable
40 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
42 ; Function Attrs: nounwind
43 declare void @llvm.stackprotector(i8*, i8**) #1
45 attributes #0 = { nounwind readnone speculatable }
46 attributes #1 = { nounwind }
49 !llvm.module.flags = !{!3, !4, !5, !6}
52 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
53 !1 = !DIFile(filename: "live-debug-values-reg-copy.c", directory: "/")
55 !3 = !{i32 2, !"Dwarf Version", i32 4}
56 !4 = !{i32 2, !"Debug Info Version", i32 3}
57 !5 = !{i32 1, !"wchar_size", i32 4}
58 !6 = !{i32 1, !"min_enum_size", i32 4}
59 !7 = !{!"clang version 7.0.0"}
60 !8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !9, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
61 !9 = !DISubroutineType(types: !10)
63 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65 !13 = !DILocalVariable(name: "arg1", arg: 1, scope: !8, file: !1, line: 4, type: !11)
66 !16 = !DILocation(line: 4, column: 13, scope: !8)
72 exposesReturnsTwice: false
74 regBankSelected: false
76 tracksRegLiveness: false
79 - { reg: '$r0', virtual-reg: '' }
81 isFrameAddressTaken: false
82 isReturnAddressTaken: false
92 hasOpaqueSPAdjustment: false
94 hasMustTailInVarArgFunc: false
99 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
100 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,
101 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
102 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
103 stack-id: default, callee-saved-register: '$r11', callee-saved-restored: true,
104 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
105 - { id: 2, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4,
106 stack-id: default, callee-saved-register: '$r5', callee-saved-restored: true,
107 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
108 - { id: 3, name: '', type: spill-slot, offset: -16, size: 4, alignment: 4,
109 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,
110 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
114 successors: %bb.1(0x40000000), %bb.2(0x40000000)
116 $sp = frame-setup STMDB_UPD $sp, 14, $noreg, killed $r4, killed $r5, killed $r11, killed $lr
117 frame-setup CFI_INSTRUCTION def_cfa_offset 16
118 frame-setup CFI_INSTRUCTION offset $lr, -4
119 frame-setup CFI_INSTRUCTION offset $r11, -8
120 frame-setup CFI_INSTRUCTION offset $r5, -12
121 frame-setup CFI_INSTRUCTION offset $r4, -16
122 DBG_VALUE $r0, $noreg, !13, !DIExpression(), debug-location !16
123 DBG_VALUE $r0, $noreg, !13, !DIExpression(), debug-location !16
124 CMPri renamable $r0, 10, 14, $noreg, implicit-def $cpsr, debug-location !16
125 Bcc %bb.2, 13, killed $cpsr, debug-location !16
128 BL @externFunc, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def dead $r0, debug-location !16
129 $r0 = MOVi 1, 14, $noreg, $noreg, debug-location !16
130 $sp = LDMIA_UPD $sp, 14, $noreg, def $r4, def $r5, def $r11, def $lr, debug-location !16
131 BX_RET 14, $noreg, implicit killed $r0, debug-location !16
134 renamable $r4 = ADDri killed renamable $r0, 10, 14, $noreg, $noreg, debug-location !16
135 DBG_VALUE $r4, $noreg, !13, !DIExpression(), debug-location !16
136 $r0 = MOVr $r4, 14, $noreg, $noreg, debug-location !16
137 BL @externFunc2, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def $r0, debug-location !16
138 $r5 = MOVr killed $r0, 14, $noreg, $noreg, debug-location !16
139 $r0 = MOVr $r4, 14, $noreg, $noreg, debug-location !16
140 BL @externFunc, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def dead $r0, debug-location !16
141 $r0 = MOVr killed $r5, 14, $noreg, $noreg, debug-location !16
142 ; Instruction below is added in order to test moving variable's value from one register to another.
143 $r5 = MOVr killed $r4, 14, $noreg, $noreg, debug-location !16
144 $sp = LDMIA_UPD $sp, 14, $noreg, def $r4, def $r5, def $r11, def $lr, debug-location !16
145 BX_RET 14, $noreg, implicit killed $r0, debug-location !16