1 # RUN: llc %s -run-pass=machine-cp -o - | FileCheck %s --implicit-check-not=DBG_VALUE
3 ## Ensure that when the destination register of a copy instruction is used by a
4 ## DBG_VALUE/DBG_VALUE_LIST, and then that instruction is deleted during copy
5 ## propagation, the debug use is updated to the source register.
7 # CHECK: ![[VAR_V:[0-9]+]] = !DILocalVariable(name: "v"
10 # CHECK: DBG_VALUE $r0, $noreg, ![[VAR_V]], !DIExpression()
11 # CHECK: DBG_VALUE_LIST ![[VAR_V]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 4, DW_OP_mul, DW_OP_plus, DW_OP_stack_value), $r0, 0
14 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
15 target triple = "arm-unknown-linux-gnueabi"
17 %struct.atomic_t.0.6.15.24.48.51.54.57 = type { i32 }
18 %struct.mm_struct.2.8.17.26.50.53.56.59 = type { %struct.anon.1.7.16.25.49.52.55.58 }
19 %struct.anon.1.7.16.25.49.52.55.58 = type { i32 }
21 @dup_mm_err = external dso_local local_unnamed_addr global i32, align 4, !dbg !0
23 declare dso_local i32 @atomic_long_read(%struct.atomic_t.0.6.15.24.48.51.54.57*) local_unnamed_addr #0
25 declare dso_local i32 @get_mm_counter(%struct.mm_struct.2.8.17.26.50.53.56.59*, i32) local_unnamed_addr #0
27 define dso_local i32 @dup_mm() local_unnamed_addr !dbg !16 {
29 %call = tail call i32 bitcast (i32 (...)* @kmem_cache_alloc to i32 (i32)*)(i32 0)
30 br i1 undef, label %cleanup, label %if.end
32 if.end: ; preds = %entry
33 %tobool1.not = icmp eq i32 undef, 0
34 br i1 %tobool1.not, label %if.end3, label %free_pt
36 if.end3: ; preds = %if.end
37 call void @llvm.dbg.value(metadata !DIArgList(i32 %call, i32 0), metadata !30, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 4, DW_OP_mul, DW_OP_plus, DW_OP_stack_value)), !dbg !40
38 %0 = load volatile i32, i32* undef, align 4
41 free_pt: ; preds = %if.end
42 store i32 0, i32* undef, align 4
45 cleanup: ; preds = %free_pt, %if.end3, %entry
46 %retval.0 = phi i32 [ %call, %if.end3 ], [ 0, %entry ], [ 0, %free_pt ]
50 declare dso_local i32 @kmem_cache_alloc(...) local_unnamed_addr
52 declare void @llvm.dbg.label(metadata)
54 declare void @llvm.dbg.value(metadata, metadata, metadata)
57 !llvm.module.flags = !{!14, !15}
59 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
60 !1 = distinct !DIGlobalVariable(name: "dup_mm_err", scope: !2, file: !3, line: 5, type: !12, isLocal: false, isDefinition: true)
61 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !9, globals: !13, splitDebugInlining: false, nameTableKind: None)
62 !3 = !DIFile(filename: "machine-cp-updates-dbg-reg.ll", directory: "/")
64 !5 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !3, line: 4, baseType: !6, size: 32, elements: !7)
65 !6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
67 !8 = !DIEnumerator(name: "MM_SHMEMPAGES", value: 0, isUnsigned: true)
69 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32)
70 !11 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !12)
71 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
73 !14 = !{i32 2, !"Debug Info Version", i32 3}
74 !15 = !{i32 1, !"min_enum_size", i32 4}
75 !16 = distinct !DISubprogram(name: "dup_mm", scope: !3, file: !3, line: 14, type: !17, scopeLine: 14, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !19)
76 !17 = !DISubroutineType(types: !18)
78 !19 = !{!20, !28, !29}
79 !20 = !DILocalVariable(name: "mm", scope: !16, file: !3, line: 15, type: !21)
80 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32)
81 !22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "mm_struct", file: !3, line: 7, size: 32, elements: !23)
83 !24 = !DIDerivedType(tag: DW_TAG_member, scope: !22, file: !3, line: 8, baseType: !25, size: 32)
84 !25 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !22, file: !3, line: 8, size: 32, elements: !26)
86 !27 = !DIDerivedType(tag: DW_TAG_member, name: "binfmt", scope: !25, file: !3, line: 9, baseType: !12, size: 32)
87 !28 = !DILabel(scope: !16, name: "free_pt", file: !3, line: 22)
88 !29 = !DILabel(scope: !16, name: "fail_nomem", file: !3, line: 24)
89 !30 = !DILocalVariable(name: "v", arg: 1, scope: !31, file: !3, line: 6, type: !34)
90 !31 = distinct !DISubprogram(name: "atomic_long_read", scope: !3, file: !3, line: 6, type: !32, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !39)
91 !32 = !DISubroutineType(types: !33)
93 !34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !35, size: 32)
94 !35 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !3, line: 3, baseType: !36)
95 !36 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !3, line: 1, size: 32, elements: !37)
97 !38 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !36, file: !3, line: 2, baseType: !12, size: 32)
99 !40 = !DILocation(line: 0, scope: !31, inlinedAt: !41)
100 !41 = distinct !DILocation(line: 12, column: 3, scope: !42, inlinedAt: !48)
101 !42 = distinct !DISubprogram(name: "get_mm_counter", scope: !3, file: !3, line: 11, type: !43, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !45)
102 !43 = !DISubroutineType(types: !44)
103 !44 = !{!22, !21, !12}
105 !46 = !DILocalVariable(name: "mm", arg: 1, scope: !42, file: !3, line: 11, type: !21)
106 !47 = !DILocalVariable(name: "member", arg: 2, scope: !42, file: !3, line: 11, type: !12)
107 !48 = distinct !DILocation(line: 20, column: 3, scope: !16)
113 exposesReturnsTwice: false
115 regBankSelected: false
118 tracksRegLiveness: true
123 isFrameAddressTaken: false
124 isReturnAddressTaken: false
134 cvBytesOfCalleeSavedRegisters: 0
135 hasOpaqueSPAdjustment: false
137 hasMustTailInVarArgFunc: false
144 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
145 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
146 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
147 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
148 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,
149 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
151 debugValueSubstitutions: []
153 machineFunctionInfo: {}
156 successors: %bb.4(0x40000000), %bb.1(0x40000000)
159 $sp = frame-setup STMDB_UPD $sp, 14 /* CC::al */, $noreg, killed $r4, killed $lr
160 frame-setup CFI_INSTRUCTION def_cfa_offset 8
161 frame-setup CFI_INSTRUCTION offset $lr, -4
162 frame-setup CFI_INSTRUCTION offset $r4, -8
163 renamable $r4 = MOVi 0, 14 /* CC::al */, $noreg, $noreg
164 $r0 = MOVi 0, 14 /* CC::al */, $noreg, $noreg
165 BL @kmem_cache_alloc, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit-def $sp, implicit-def $r0
166 CMPri renamable $r4, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
167 Bcc %bb.4, 1 /* CC::ne */, killed $cpsr
170 successors: %bb.2(0x30000000), %bb.3(0x50000000)
173 renamable $r4 = MOVi 0, 14 /* CC::al */, $noreg, $noreg
174 CMPri renamable $r4, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
175 Bcc %bb.3, 1 /* CC::ne */, killed $cpsr
180 dead renamable $r1 = LDRi12 undef renamable $r0, 0, 14 /* CC::al */, $noreg :: (volatile load (s32) from `i32* undef`)
181 renamable $r4 = COPY killed renamable $r0
182 DBG_VALUE $r4, $noreg, !30, !DIExpression(), debug-location !40
183 DBG_VALUE_LIST !30, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 4, DW_OP_mul, DW_OP_plus, DW_OP_stack_value), $r4, 0, debug-location !40
184 $r0 = COPY killed renamable $r4
185 $sp = frame-destroy LDMIA_RET $sp, 14 /* CC::al */, $noreg, def $r4, def $pc, implicit $r0
188 successors: %bb.4(0x80000000)
191 STRi12 renamable $r4, undef renamable $r0, 0, 14 /* CC::al */, $noreg :: (store (s32) into `i32* undef`)
196 $r0 = COPY killed renamable $r4
197 $sp = frame-destroy LDMIA_RET $sp, 14 /* CC::al */, $noreg, def $r4, def $pc, implicit $r0