1# RUN: llc -run-pass=livedebugvalues %s -o - -experimental-debug-variable-locations | FileCheck %s --check-prefixes=CHECK 2 3# Test that we do not drop debug values when joining a VPHI and a Def that use 4# the same value. 5# In this test case, the live out value for "a" from bb.4 is a VPHI with a 6# defined value, the value live-in register $esi at bb.3. In bb.5, we also have 7# a DBG_INSTR_REF that explicitly defines "a" as holding that same value. When 8# joining these values to determine the live-in value of "a" at bb.6, we should 9# recognize that these values are identical and produce a valid live-in debug 10# value. 11 12# CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "a" 13 14# CHECK-LABEL: bb.6 15# CHECK: DBG_VALUE_LIST ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0), $esi 16 17--- | 18 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 19 target triple = "x86_64-unknown-linux-gnu" 20 21 ; Function Attrs: mustprogress uwtable 22 define dso_local noundef i32 @"?foo@@YAHH@Z"(i32 noundef %0) local_unnamed_addr #0 !dbg !8 { 23 call void @llvm.dbg.value(metadata i32 %0, metadata !14, metadata !DIExpression()), !dbg !16 24 %2 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !17 25 br label %3, !dbg !18 26 27 3: ; preds = %13, %1 28 %4 = phi i32 [ %0, %1 ], [ %14, %13 ] 29 %5 = phi i32 [ %2, %1 ], [ %7, %13 ], !dbg !16 30 call void @llvm.dbg.value(metadata i32 %4, metadata !14, metadata !DIExpression()), !dbg !16 31 %6 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !19 32 %7 = sub nsw i32 %5, %6, !dbg !19 33 %8 = srem i32 %7, 3, !dbg !21 34 %9 = icmp eq i32 %8, 0, !dbg !21 35 br i1 %9, label %10, label %13, !dbg !21 36 37 10: ; preds = %3 38 %11 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !22 39 %12 = add nsw i32 %11, %4, !dbg !22 40 call void @llvm.dbg.value(metadata i32 %12, metadata !14, metadata !DIExpression()), !dbg !16 41 br label %13, !dbg !25 42 43 13: ; preds = %10, %3 44 %14 = phi i32 [ %12, %10 ], [ %4, %3 ] 45 call void @llvm.dbg.value(metadata i32 %14, metadata !14, metadata !DIExpression()), !dbg !16 46 %15 = icmp sgt i32 %7, 0, !dbg !26 47 br i1 %15, label %3, label %16, !dbg !26, !llvm.loop !27 48 49 16: ; preds = %13 50 %17 = and i32 %7, 1, !dbg !30 51 %18 = icmp eq i32 %17, 0, !dbg !30 52 br i1 %18, label %19, label %22, !dbg !30 53 54 19: ; preds = %16 55 %20 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !31 56 %21 = add nsw i32 %20, %14, !dbg !31 57 call void @llvm.dbg.value(metadata i32 %21, metadata !14, metadata !DIExpression()), !dbg !16 58 br label %22, !dbg !34 59 60 22: ; preds = %19, %16 61 %23 = phi i32 [ %21, %19 ], [ %14, %16 ], !dbg !16 62 call void @llvm.dbg.value(metadata i32 %23, metadata !14, metadata !DIExpression()), !dbg !16 63 ret i32 %23, !dbg !35 64 } 65 66 declare dso_local noundef i32 @"?bar@@YAHXZ"() local_unnamed_addr #1 67 68 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn 69 declare void @llvm.dbg.value(metadata, metadata, metadata) #2 70 71 attributes #0 = { mustprogress uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } 72 attributes #1 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } 73 attributes #2 = { nocallback nofree nosync nounwind readnone speculatable willreturn } 74 75 !llvm.dbg.cu = !{!0} 76 !llvm.module.flags = !{!3, !4, !5, !6} 77 !llvm.ident = !{!7} 78 79 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) 80 !1 = !DIFile(filename: "test.cpp", directory: "\") 81 !3 = !{i32 2, !"Debug Info Version", i32 3} 82 !4 = !{i32 1, !"wchar_size", i32 2} 83 !5 = !{i32 7, !"PIC Level", i32 2} 84 !6 = !{i32 7, !"uwtable", i32 2} 85 !7 = !{!"clang version 15.0.0"} 86 !8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHH@Z", scope: !9, file: !9, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) 87 !9 = !DIFile(filename: ".\\test.cpp", directory: "\") 88 !10 = !DISubroutineType(types: !11) 89 !11 = !{!12, !12} 90 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 91 !13 = !{!14} 92 !14 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 3, type: !12) 93 !16 = !DILocation(line: 0, scope: !8) 94 !17 = !DILocation(line: 4, scope: !8) 95 !18 = !DILocation(line: 5, scope: !8) 96 !19 = !DILocation(line: 6, scope: !20) 97 !20 = distinct !DILexicalBlock(scope: !8, file: !9, line: 5) 98 !21 = !DILocation(line: 7, scope: !20) 99 !22 = !DILocation(line: 8, scope: !23) 100 !23 = distinct !DILexicalBlock(scope: !24, file: !9, line: 7) 101 !24 = distinct !DILexicalBlock(scope: !20, file: !9, line: 7) 102 !25 = !DILocation(line: 9, scope: !23) 103 !26 = !DILocation(line: 10, scope: !20) 104 !27 = distinct !{!27, !18, !28, !29} 105 !28 = !DILocation(line: 10, scope: !8) 106 !29 = !{!"llvm.loop.mustprogress"} 107 !30 = !DILocation(line: 11, scope: !8) 108 !31 = !DILocation(line: 12, scope: !32) 109 !32 = distinct !DILexicalBlock(scope: !33, file: !9, line: 11) 110 !33 = distinct !DILexicalBlock(scope: !8, file: !9, line: 11) 111 !34 = !DILocation(line: 13, scope: !32) 112 !35 = !DILocation(line: 14, scope: !8) 113 114... 115--- 116name: '?foo@@YAHH@Z' 117alignment: 16 118exposesReturnsTwice: false 119legalized: false 120regBankSelected: false 121selected: false 122failedISel: false 123tracksRegLiveness: true 124hasWinCFI: true 125callsEHReturn: false 126callsUnwindInit: false 127hasEHCatchret: false 128hasEHScopes: false 129hasEHFunclets: false 130failsVerification: false 131tracksDebugUserValues: true 132debugInstrRef: true 133registers: [] 134liveins: 135 - { reg: '$ecx', virtual-reg: '' } 136frameInfo: 137 isFrameAddressTaken: false 138 isReturnAddressTaken: false 139 hasStackMap: false 140 hasPatchPoint: false 141 stackSize: 56 142 offsetAdjustment: -56 143 maxAlignment: 8 144 adjustsStack: true 145 hasCalls: true 146 stackProtector: '' 147 functionContext: '' 148 maxCallFrameSize: 32 149 cvBytesOfCalleeSavedRegisters: 16 150 hasOpaqueSPAdjustment: false 151 hasVAStart: false 152 hasMustTailInVarArgFunc: false 153 hasTailCall: false 154 localFrameSize: 0 155 savePoint: '' 156 restorePoint: '' 157fixedStack: 158 - { id: 0, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default, 159 callee-saved-register: '$rdi', callee-saved-restored: true, debug-info-variable: '', 160 debug-info-expression: '', debug-info-location: '' } 161 - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default, 162 callee-saved-register: '$rsi', callee-saved-restored: true, debug-info-variable: '', 163 debug-info-expression: '', debug-info-location: '' } 164stack: [] 165callSites: [] 166debugValueSubstitutions: [] 167constants: [] 168machineFunctionInfo: {} 169body: | 170 bb.0 (%ir-block.1): 171 successors: %bb.1(0x80000000) 172 liveins: $ecx, $rsi, $rdi 173 174 DBG_VALUE $ecx, $noreg, !14, !DIExpression(), debug-location !16 175 frame-setup PUSH64r killed $rsi, implicit-def $rsp, implicit $rsp 176 frame-setup SEH_PushReg 57 177 frame-setup PUSH64r killed $rdi, implicit-def $rsp, implicit $rsp 178 frame-setup SEH_PushReg 53 179 $rsp = frame-setup SUB64ri8 $rsp, 40, implicit-def dead $eflags 180 frame-setup SEH_StackAlloc 40 181 frame-setup SEH_EndPrologue 182 $esi = MOV32rr $ecx 183 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-instr-number 8, debug-location !17 184 $edi = MOV32rr $eax, debug-location !17 185 JMP_1 %bb.1 186 187 bb.3 (%ir-block.13, align 16): 188 successors: %bb.1(0x7c000000), %bb.4(0x04000000) 189 liveins: $edi, $esi 190 191 DBG_PHI $esi, 5 192 TEST32rr renamable $edi, renamable $edi, implicit-def $eflags, debug-location !26 193 JCC_1 %bb.4, 14, implicit $eflags, debug-location !26 194 195 bb.1 (%ir-block.3): 196 successors: %bb.2(0x30000000), %bb.3(0x50000000) 197 liveins: $edi, $esi 198 199 DBG_PHI $esi, 3 200 DBG_PHI $edi, 2 201 DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 0), debug-location !16 202 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !19 203 renamable $edi = nsw SUB32rr killed renamable $edi, killed renamable $eax, implicit-def dead $eflags, debug-instr-number 1, debug-location !19 204 renamable $eax = IMUL32rri renamable $edi, -1431655765, implicit-def dead $eflags, debug-location !21 205 renamable $eax = ADD32ri killed renamable $eax, 715827882, implicit-def dead $eflags, debug-location !21 206 CMP32ri killed renamable $eax, 1431655764, implicit-def $eflags, debug-location !21 207 JCC_1 %bb.3, 7, implicit $eflags, debug-location !21 208 209 bb.2 (%ir-block.10): 210 successors: %bb.3(0x80000000) 211 liveins: $edi, $esi 212 213 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !22 214 renamable $esi = nsw ADD32rr killed renamable $esi, killed renamable $eax, implicit-def dead $eflags, debug-instr-number 4, debug-location !22 215 DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(4, 0), debug-location !16 216 JMP_1 %bb.3 217 218 bb.4 (%ir-block.16): 219 successors: %bb.5(0x40000000), %bb.6(0x40000000) 220 liveins: $edi, $esi 221 222 TEST8ri renamable $dil, 1, implicit-def $eflags, implicit killed $edi, debug-location !30 223 JCC_1 %bb.6, 5, implicit $eflags, debug-location !30 224 225 bb.5 (%ir-block.19): 226 successors: %bb.6(0x80000000) 227 liveins: $esi 228 229 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !31 230 DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !16 231 232 bb.6 (%ir-block.22): 233 liveins: $esi 234 235 $eax = MOV32rr killed $esi, debug-location !35 236 SEH_Epilogue debug-location !35 237 $rsp = frame-destroy ADD64ri8 $rsp, 40, implicit-def dead $eflags, debug-location !35 238 $rdi = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !35 239 $rsi = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !35 240 RET64 $eax, debug-location !35 241 242... 243