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 ## Do the same for DBG_PHI instructions.
9 # CHECK: ![[VAR_V:[0-9]+]] = !DILocalVariable(name: "v"
12 # CHECK: DBG_PHI $r0, 1
13 # CHECK: DBG_VALUE $r0, $noreg, ![[VAR_V]], !DIExpression()
14 # 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
17 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
18 target triple = "arm-unknown-linux-gnueabi"
20 %struct.atomic_t.0.6.15.24.48.51.54.57 = type { i32 }
21 %struct.mm_struct.2.8.17.26.50.53.56.59 = type { %struct.anon.1.7.16.25.49.52.55.58 }
22 %struct.anon.1.7.16.25.49.52.55.58 = type { i32 }
24 @dup_mm_err = external dso_local local_unnamed_addr global i32, align 4, !dbg !0
26 declare dso_local i32 @atomic_long_read(%struct.atomic_t.0.6.15.24.48.51.54.57*) local_unnamed_addr #0
28 declare dso_local i32 @get_mm_counter(%struct.mm_struct.2.8.17.26.50.53.56.59*, i32) local_unnamed_addr #0
30 define dso_local i32 @dup_mm() local_unnamed_addr !dbg !16 {
32 %call = tail call i32 bitcast (i32 (...)* @kmem_cache_alloc to i32 (i32)*)(i32 0)
33 br i1 undef, label %cleanup, label %if.end
35 if.end: ; preds = %entry
36 %tobool1.not = icmp eq i32 undef, 0
37 br i1 %tobool1.not, label %if.end3, label %free_pt
39 if.end3: ; preds = %if.end
40 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
41 %0 = load volatile i32, i32* undef, align 4
44 free_pt: ; preds = %if.end
45 store i32 0, i32* undef, align 4
48 cleanup: ; preds = %free_pt, %if.end3, %entry
49 %retval.0 = phi i32 [ %call, %if.end3 ], [ 0, %entry ], [ 0, %free_pt ]
53 declare dso_local i32 @kmem_cache_alloc(...) local_unnamed_addr
55 declare void @llvm.dbg.label(metadata)
57 declare void @llvm.dbg.value(metadata, metadata, metadata)
60 !llvm.module.flags = !{!14, !15}
62 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
63 !1 = distinct !DIGlobalVariable(name: "dup_mm_err", scope: !2, file: !3, line: 5, type: !12, isLocal: false, isDefinition: true)
64 !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)
65 !3 = !DIFile(filename: "machine-cp-updates-dbg-reg.ll", directory: "/")
67 !5 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !3, line: 4, baseType: !6, size: 32, elements: !7)
68 !6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
70 !8 = !DIEnumerator(name: "MM_SHMEMPAGES", value: 0, isUnsigned: true)
72 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32)
73 !11 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !12)
74 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
76 !14 = !{i32 2, !"Debug Info Version", i32 3}
77 !15 = !{i32 1, !"min_enum_size", i32 4}
78 !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)
79 !17 = !DISubroutineType(types: !18)
81 !19 = !{!20, !28, !29}
82 !20 = !DILocalVariable(name: "mm", scope: !16, file: !3, line: 15, type: !21)
83 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32)
84 !22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "mm_struct", file: !3, line: 7, size: 32, elements: !23)
86 !24 = !DIDerivedType(tag: DW_TAG_member, scope: !22, file: !3, line: 8, baseType: !25, size: 32)
87 !25 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !22, file: !3, line: 8, size: 32, elements: !26)
89 !27 = !DIDerivedType(tag: DW_TAG_member, name: "binfmt", scope: !25, file: !3, line: 9, baseType: !12, size: 32)
90 !28 = !DILabel(scope: !16, name: "free_pt", file: !3, line: 22)
91 !29 = !DILabel(scope: !16, name: "fail_nomem", file: !3, line: 24)
92 !30 = !DILocalVariable(name: "v", arg: 1, scope: !31, file: !3, line: 6, type: !34)
93 !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)
94 !32 = !DISubroutineType(types: !33)
96 !34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !35, size: 32)
97 !35 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !3, line: 3, baseType: !36)
98 !36 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !3, line: 1, size: 32, elements: !37)
100 !38 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !36, file: !3, line: 2, baseType: !12, size: 32)
102 !40 = !DILocation(line: 0, scope: !31, inlinedAt: !41)
103 !41 = distinct !DILocation(line: 12, column: 3, scope: !42, inlinedAt: !48)
104 !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)
105 !43 = !DISubroutineType(types: !44)
106 !44 = !{!22, !21, !12}
108 !46 = !DILocalVariable(name: "mm", arg: 1, scope: !42, file: !3, line: 11, type: !21)
109 !47 = !DILocalVariable(name: "member", arg: 2, scope: !42, file: !3, line: 11, type: !12)
110 !48 = distinct !DILocation(line: 20, column: 3, scope: !16)
116 exposesReturnsTwice: false
118 regBankSelected: false
121 tracksRegLiveness: true
126 isFrameAddressTaken: false
127 isReturnAddressTaken: false
137 cvBytesOfCalleeSavedRegisters: 0
138 hasOpaqueSPAdjustment: false
140 hasMustTailInVarArgFunc: false
147 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
148 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false,
149 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
150 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
151 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,
152 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
154 debugValueSubstitutions: []
156 machineFunctionInfo: {}
159 successors: %bb.4(0x40000000), %bb.1(0x40000000)
162 $sp = frame-setup STMDB_UPD $sp, 14 /* CC::al */, $noreg, killed $r4, killed $lr
163 frame-setup CFI_INSTRUCTION def_cfa_offset 8
164 frame-setup CFI_INSTRUCTION offset $lr, -4
165 frame-setup CFI_INSTRUCTION offset $r4, -8
166 renamable $r4 = MOVi 0, 14 /* CC::al */, $noreg, $noreg
167 $r0 = MOVi 0, 14 /* CC::al */, $noreg, $noreg
168 BL @kmem_cache_alloc, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit-def $sp, implicit-def $r0
169 CMPri renamable $r4, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
170 Bcc %bb.4, 1 /* CC::ne */, killed $cpsr
173 successors: %bb.2(0x30000000), %bb.3(0x50000000)
176 renamable $r4 = MOVi 0, 14 /* CC::al */, $noreg, $noreg
177 CMPri renamable $r4, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
178 Bcc %bb.3, 1 /* CC::ne */, killed $cpsr
183 dead renamable $r1 = LDRi12 undef renamable $r0, 0, 14 /* CC::al */, $noreg :: (volatile load (s32) from `i32* undef`)
184 renamable $r4 = COPY killed renamable $r0
186 DBG_VALUE $r4, $noreg, !30, !DIExpression(), debug-location !40
187 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
188 $r0 = COPY killed renamable $r4
189 $sp = frame-destroy LDMIA_RET $sp, 14 /* CC::al */, $noreg, def $r4, def $pc, implicit $r0
192 successors: %bb.4(0x80000000)
195 STRi12 renamable $r4, undef renamable $r0, 0, 14 /* CC::al */, $noreg :: (store (s32) into `i32* undef`)
200 $r0 = COPY killed renamable $r4
201 $sp = frame-destroy LDMIA_RET $sp, 14 /* CC::al */, $noreg, def $r4, def $pc, implicit $r0