244 lines · plain
1# RUN: llc -run-pass=livedebugvalues %s -o - -experimental-debug-variable-locations | FileCheck %s --check-prefixes=CHECK2 3# Test that we do not drop debug values when joining a VPHI and a Def that use4# the same value.5# In this test case, the live out value for "a" from bb.4 is a VPHI with a6# defined value, the value live-in register $esi at bb.3. In bb.5, we also have7# a DBG_INSTR_REF that explicitly defines "a" as holding that same value. When8# joining these values to determine the live-in value of "a" at bb.6, we should9# recognize that these values are identical and produce a valid live-in debug10# value.11 12# CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "a"13 14# CHECK-LABEL: bb.615# CHECK: DBG_VALUE_LIST ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0), $esi16 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 uwtable22 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 !1624 %2 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !1725 br label %3, !dbg !1826 27 3: ; preds = %13, %128 %4 = phi i32 [ %0, %1 ], [ %14, %13 ]29 %5 = phi i32 [ %2, %1 ], [ %7, %13 ], !dbg !1630 call void @llvm.dbg.value(metadata i32 %4, metadata !14, metadata !DIExpression()), !dbg !1631 %6 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !1932 %7 = sub nsw i32 %5, %6, !dbg !1933 %8 = srem i32 %7, 3, !dbg !2134 %9 = icmp eq i32 %8, 0, !dbg !2135 br i1 %9, label %10, label %13, !dbg !2136 37 10: ; preds = %338 %11 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !2239 %12 = add nsw i32 %11, %4, !dbg !2240 call void @llvm.dbg.value(metadata i32 %12, metadata !14, metadata !DIExpression()), !dbg !1641 br label %13, !dbg !2542 43 13: ; preds = %10, %344 %14 = phi i32 [ %12, %10 ], [ %4, %3 ]45 call void @llvm.dbg.value(metadata i32 %14, metadata !14, metadata !DIExpression()), !dbg !1646 %15 = icmp sgt i32 %7, 0, !dbg !2647 br i1 %15, label %3, label %16, !dbg !26, !llvm.loop !2748 49 16: ; preds = %1350 %17 = and i32 %7, 1, !dbg !3051 %18 = icmp eq i32 %17, 0, !dbg !3052 br i1 %18, label %19, label %22, !dbg !3053 54 19: ; preds = %1655 %20 = tail call noundef i32 @"?bar@@YAHXZ"(), !dbg !3156 %21 = add nsw i32 %20, %14, !dbg !3157 call void @llvm.dbg.value(metadata i32 %21, metadata !14, metadata !DIExpression()), !dbg !1658 br label %22, !dbg !3459 60 22: ; preds = %19, %1661 %23 = phi i32 [ %21, %19 ], [ %14, %16 ], !dbg !1662 call void @llvm.dbg.value(metadata i32 %23, metadata !14, metadata !DIExpression()), !dbg !1663 ret i32 %23, !dbg !3564 }65 66 declare dso_local noundef i32 @"?bar@@YAHXZ"() local_unnamed_addr #167 68 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn69 declare void @llvm.dbg.value(metadata, metadata, metadata) #270 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: 16118exposesReturnsTwice: false119legalized: false120regBankSelected: false121selected: false122failedISel: false123tracksRegLiveness: true124hasWinCFI: true125callsEHReturn: false126callsUnwindInit: false127hasEHContTarget: false128hasEHScopes: false129hasEHFunclets: false130failsVerification: false131tracksDebugUserValues: true132debugInstrRef: true133registers: []134liveins:135 - { reg: '$ecx', virtual-reg: '' }136frameInfo:137 isFrameAddressTaken: false138 isReturnAddressTaken: false139 hasStackMap: false140 hasPatchPoint: false141 stackSize: 56142 offsetAdjustment: -56143 maxAlignment: 8144 adjustsStack: true145 hasCalls: true146 stackProtector: ''147 functionContext: ''148 maxCallFrameSize: 32149 cvBytesOfCalleeSavedRegisters: 16150 hasOpaqueSPAdjustment: false151 hasVAStart: false152 hasMustTailInVarArgFunc: false153 hasTailCall: false154 localFrameSize: 0155 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, $rdi173 174 DBG_VALUE $ecx, $noreg, !14, !DIExpression(), debug-location !16175 frame-setup PUSH64r killed $rsi, implicit-def $rsp, implicit $rsp176 frame-setup SEH_PushReg 57177 frame-setup PUSH64r killed $rdi, implicit-def $rsp, implicit $rsp178 frame-setup SEH_PushReg 53179 $rsp = frame-setup SUB64ri8 $rsp, 40, implicit-def dead $eflags180 frame-setup SEH_StackAlloc 40181 frame-setup SEH_EndPrologue182 $esi = MOV32rr $ecx183 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-instr-number 8, debug-location !17184 $edi = MOV32rr $eax, debug-location !17185 JMP_1 %bb.1186 187 bb.3 (%ir-block.13, align 16):188 successors: %bb.1(0x7c000000), %bb.4(0x04000000)189 liveins: $edi, $esi190 191 DBG_PHI $esi, 5192 TEST32rr renamable $edi, renamable $edi, implicit-def $eflags, debug-location !26193 JCC_1 %bb.4, 14, implicit $eflags, debug-location !26194 195 bb.1 (%ir-block.3):196 successors: %bb.2(0x30000000), %bb.3(0x50000000)197 liveins: $edi, $esi198 199 DBG_PHI $esi, 3200 DBG_PHI $edi, 2201 DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 0), debug-location !16202 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !19203 renamable $edi = nsw SUB32rr killed renamable $edi, killed renamable $eax, implicit-def dead $eflags, debug-instr-number 1, debug-location !19204 renamable $eax = IMUL32rri renamable $edi, -1431655765, implicit-def dead $eflags, debug-location !21205 renamable $eax = ADD32ri killed renamable $eax, 715827882, implicit-def dead $eflags, debug-location !21206 CMP32ri killed renamable $eax, 1431655764, implicit-def $eflags, debug-location !21207 JCC_1 %bb.3, 7, implicit $eflags, debug-location !21208 209 bb.2 (%ir-block.10):210 successors: %bb.3(0x80000000)211 liveins: $edi, $esi212 213 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !22214 renamable $esi = nsw ADD32rr killed renamable $esi, killed renamable $eax, implicit-def dead $eflags, debug-instr-number 4, debug-location !22215 DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(4, 0), debug-location !16216 JMP_1 %bb.3217 218 bb.4 (%ir-block.16):219 successors: %bb.5(0x40000000), %bb.6(0x40000000)220 liveins: $edi, $esi221 222 TEST8ri renamable $dil, 1, implicit-def $eflags, implicit killed $edi, debug-location !30223 JCC_1 %bb.6, 5, implicit $eflags, debug-location !30224 225 bb.5 (%ir-block.19):226 successors: %bb.6(0x80000000)227 liveins: $esi228 229 CALL64pcrel32 @"?bar@@YAHXZ", csr_win64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !31230 DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !16231 232 bb.6 (%ir-block.22):233 liveins: $esi234 235 $eax = MOV32rr killed $esi, debug-location !35236 SEH_BeginEpilogue debug-location !35237 $rsp = frame-destroy ADD64ri8 $rsp, 40, implicit-def dead $eflags, debug-location !35238 $rdi = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !35239 $rsi = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !35240 SEH_EndEpilogue debug-location !35241 RET64 $eax, debug-location !35242 243...244