195 lines · plain
1# RUN: llc -run-pass=livedebugvalues -o - %s | FileCheck %s2 3# Based on the following C reproducer:4#5# extern void ext(int *);6# extern int interesting(int *);7# extern int *value(void);8#9# static void callee(int *p1, int *p2) {10# if (interesting(p2))11# for (;;)12# ext(p1);13# ext(p2);14# }15#16# void caller() {17# int *local = value();18# callee(local, (int *)0xabcd);19# }20#21# Generated using:22#23# clang -Os -fno-inline -Xclang -femit-debug-entry-values -g --target=armeb.24 25--- |26 target datalayout = "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"27 target triple = "armebv4t-unknown-unknown"28 29 ; Function Attrs: noinline nounwind optsize30 define arm_aapcs_vfpcc void @caller() #0 !dbg !20 {31 entry:32 unreachable33 }34 35 ; Function Attrs: noinline nounwind optsize36 define internal arm_aapcs_vfpcc void @callee(ptr %p1) unnamed_addr #0 !dbg !29 {37 entry:38 unreachable39 }40 41 declare !dbg !4 arm_aapcs_vfpcc ptr @value()42 declare !dbg !9 arm_aapcs_vfpcc i32 @interesting(ptr)43 declare !dbg !12 arm_aapcs_vfpcc void @ext(ptr)44 45 ; Function Attrs: nounwind readnone speculatable willreturn46 declare void @llvm.dbg.value(metadata, metadata, metadata) #147 48 attributes #0 = { noinline nounwind optsize "frame-pointer"="all" }49 attributes #1 = { nounwind readnone speculatable willreturn }50 51 !llvm.dbg.cu = !{!0}52 !llvm.module.flags = !{!15, !16, !17, !18}53 !llvm.ident = !{!19}54 55 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)56 !1 = !DIFile(filename: "armeb.c", directory: "/")57 !2 = !{}58 !3 = !{!4, !7, !9, !12}59 !4 = !DISubprogram(name: "value", scope: !1, file: !1, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)60 !5 = !DISubroutineType(types: !6)61 !6 = !{!7}62 !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 32)63 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)64 !9 = !DISubprogram(name: "interesting", scope: !1, file: !1, line: 2, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)65 !10 = !DISubroutineType(types: !11)66 !11 = !{!8, !7}67 !12 = !DISubprogram(name: "ext", scope: !1, file: !1, line: 1, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)68 !13 = !DISubroutineType(types: !14)69 !14 = !{null, !7}70 !15 = !{i32 2, !"Dwarf Version", i32 4}71 !16 = !{i32 2, !"Debug Info Version", i32 3}72 !17 = !{i32 1, !"wchar_size", i32 4}73 !18 = !{i32 1, !"min_enum_size", i32 4}74 !19 = !{!"clang version 10.0.0"}75 !20 = distinct !DISubprogram(name: "caller", scope: !1, file: !1, line: 12, type: !21, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !23)76 !21 = !DISubroutineType(types: !22)77 !22 = !{null}78 !23 = !{!24}79 !24 = !DILocalVariable(name: "local", scope: !20, file: !1, line: 13, type: !7)80 !25 = !DILocation(line: 13, scope: !20)81 !26 = !DILocation(line: 0, scope: !20)82 !27 = !DILocation(line: 14, scope: !20)83 !28 = !DILocation(line: 15, scope: !20)84 !29 = distinct !DISubprogram(name: "callee", scope: !1, file: !1, line: 5, type: !30, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !32)85 !30 = !DISubroutineType(types: !31)86 !31 = !{null, !7, !7}87 !32 = !{!33, !34}88 !33 = !DILocalVariable(name: "p1", arg: 1, scope: !29, file: !1, line: 5, type: !7)89 !34 = !DILocalVariable(name: "p2", arg: 2, scope: !29, file: !1, line: 5, type: !7)90 !35 = !DILocation(line: 0, scope: !29)91 !36 = !DILocation(line: 6, scope: !37)92 !37 = distinct !DILexicalBlock(scope: !29, file: !1, line: 6)93 !38 = !DILocation(line: 6, scope: !29)94 !39 = !DILocation(line: 7, scope: !40)95 !40 = distinct !DILexicalBlock(scope: !37, file: !1, line: 7)96 !41 = !DILocation(line: 8, scope: !42)97 !42 = distinct !DILexicalBlock(scope: !40, file: !1, line: 7)98 !43 = !DILocation(line: 7, scope: !42)99 !44 = distinct !{!44, !39, !45}100 !45 = !DILocation(line: 8, scope: !40)101 !46 = !DILocation(line: 9, scope: !29)102 !47 = !DILocation(line: 10, scope: !29)103 104...105---106name: caller107alignment: 4108tracksRegLiveness: true109body: |110 bb.0:111 liveins: $lr112 113 $sp = frame-setup STMDB_UPD $sp, 14, $noreg, $r11, killed $lr114 frame-setup CFI_INSTRUCTION def_cfa_offset 8115 frame-setup CFI_INSTRUCTION offset $lr, -4116 frame-setup CFI_INSTRUCTION offset $r11, -8117 $r11 = frame-setup MOVr $sp, 14, $noreg, $noreg118 frame-setup CFI_INSTRUCTION def_cfa_register $r11119 BL @value, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $r0, debug-location !25120 DBG_VALUE $r0, $noreg, !24, !DIExpression(), debug-location !26121 $sp = LDMIA_UPD $sp, 14, $noreg, def $r11, def $lr, debug-location !27122 TAILJMPd @callee, implicit $sp, implicit $sp, implicit killed $r0, debug-location !27123 124...125---126name: callee127tracksRegLiveness: true128stack:129 - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,130 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,131 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }132 - { id: 1, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,133 stack-id: default, callee-saved-register: '$r11', callee-saved-restored: true,134 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }135 - { id: 2, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4,136 stack-id: default, callee-saved-register: '$r10', callee-saved-restored: true,137 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }138 - { id: 3, name: '', type: spill-slot, offset: -16, size: 4, alignment: 4,139 stack-id: default, callee-saved-register: '$r4', callee-saved-restored: true,140 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }141body: |142 bb.0:143 successors: %bb.2(0x30000000), %bb.1(0x50000000)144 liveins: $r0, $r4, $r10, $lr145 146 DBG_VALUE $r0, $noreg, !33, !DIExpression(), debug-location !35147 $sp = frame-setup STMDB_UPD $sp, 14, $noreg, killed $r4, killed $r10, $r11, killed $lr148 frame-setup CFI_INSTRUCTION def_cfa_offset 16149 frame-setup CFI_INSTRUCTION offset $lr, -4150 frame-setup CFI_INSTRUCTION offset $r11, -8151 frame-setup CFI_INSTRUCTION offset $r10, -12152 frame-setup CFI_INSTRUCTION offset $r4, -16153 $r11 = frame-setup ADDri $sp, 8, 14, $noreg, $noreg154 frame-setup CFI_INSTRUCTION def_cfa $r11, 8155 $r4 = MOVr killed $r0, 14, $noreg, $noreg156 DBG_VALUE $r4, $noreg, !33, !DIExpression(), debug-location !35157 $r0 = MOVi 205, 14, $noreg, $noreg158 $r0 = ORRri killed $r0, 43776, 14, $noreg, $noreg159 ; The MOVI and ORRri produce the second parameter's (!34) value which has160 ; been propagated from caller().161 DBG_VALUE $r0, $noreg, !34, !DIExpression(), debug-location !35162 BL @interesting, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def $r0, debug-location !36163 CMPri killed renamable $r0, 0, 14, $noreg, implicit-def $cpsr, debug-location !38164 Bcc %bb.2, 0, killed $cpsr, debug-location !38165 166 bb.1:167 liveins: $r4168 169 $r0 = MOVr $r4, 14, $noreg, $noreg, debug-location !41170 BL @ext, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, debug-location !41171 B %bb.1, debug-location !43172 173 bb.2:174 $r0 = MOVi 205, 14, $noreg, $noreg175 $r0 = ORRri killed $r0, 43776, 14, $noreg, $noreg176 $sp = LDMIA_UPD $sp, 14, $noreg, def $r4, def $r10, def $r11, def $lr, debug-location !46177 TAILJMPd @ext, implicit $sp, implicit $sp, implicit killed $r0, debug-location !46178 179...180 181# In this test case the second parameter's value has been propagated from the182# caller to the callee, so we should not emit any entry value DBG_VALUEs for183# that parameter. The second parameter reuses the first parameter's register184# ($r0), and previously we would incorrectly emit an entry value for the185# parameter using that register.186 187# CHECK-DAG: ![[P1:[0-9]+]] = !DILocalVariable(name: "p1", arg: 1188# CHECK-DAG: ![[P2:[0-9]+]] = !DILocalVariable(name: "p2", arg: 2189 190# CHECK-NOT: DBG_VALUE $r0, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_entry_value191 192# CHECK: DBG_VALUE $r0, $noreg, ![[P1]], !DIExpression(DW_OP_LLVM_entry_value193 194# CHECK-NOT: DBG_VALUE $r0, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_entry_value195