142 lines · plain
1# RUN: llc --run-pass=livedebugvalues %s -o - -experimental-debug-variable-locations | FileCheck %s --check-prefixes=CHECK2 3# Test that we accurately track variables through transfers and clobbers.4 5# In this test case, the value of "b" is found in $rax. From there it is moved6# to $r15, $rax is killed, the value is moved back from $r15 into $rax again,7# and then $r15 is killed. Throughout this, we should track "b" and end up with8# DBG_VALUEs pointing to $rax, then $r15, then $rax again.9 10# CHECK-LABEL: bb.0.entry:11# CHECK: DBG_VALUE $rax,12# CHECK: $r15 = MOV64rr13 14## Technically it's correct to insert the DBG_VALUE for $r15 either immediately15## after the move to $r15 or immediately after $rax is clobbered, but no later.16# CHECK: DBG_VALUE $r15,17# CHECK: $rax = LEA64r18# CHECK: $rax = MOV64rr19 20## Again, the DBG_VALUE can come either after the copy to $rax or the kill of21## $r15, but no later.22# CHECK: $r15 = LEA64r23# CHECK: DBG_VALUE $rax,24# CHECK: RET6425 26--- |27 ; ModuleID = 'test.cpp'28 source_filename = "test.cpp"29 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"30 target triple = "x86_64-unknown-linux-gnu"31 32 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable33 define dso_local noundef i64 @_Z3fooxx(i64 noundef %a, i64 noundef %b) local_unnamed_addr !dbg !7 {34 entry:35 call void @llvm.dbg.value(metadata i64 %a, metadata !12, metadata !DIExpression()), !dbg !1636 call void @llvm.dbg.value(metadata i64 %b, metadata !13, metadata !DIExpression()), !dbg !1637 %add = add nsw i64 %b, %a, !dbg !1738 call void @llvm.dbg.value(metadata i64 %add, metadata !14, metadata !DIExpression()), !dbg !1639 %mul17 = sub i64 %a, %b, !dbg !1840 %sub = mul i64 %add, %mul17, !dbg !1841 call void @llvm.dbg.value(metadata i64 %sub, metadata !15, metadata !DIExpression()), !dbg !1642 %add2 = add nsw i64 %sub, %add, !dbg !1943 ret i64 %add2, !dbg !2044 }45 46 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn47 declare void @llvm.dbg.value(metadata, metadata, metadata)48 49 !llvm.dbg.cu = !{!0}50 !llvm.module.flags = !{!2, !3, !4, !5}51 !llvm.ident = !{!6}52 53 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 44673278e029d7a6f56c8a3177247026b831720f)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)54 !1 = !DIFile(filename: "test.cpp", directory: "/home/stozer/dev/llvm-project-build", checksumkind: CSK_MD5, checksum: "1e1c19354b0e967af705e204e8740d56")55 !2 = !{i32 7, !"Dwarf Version", i32 5}56 !3 = !{i32 2, !"Debug Info Version", i32 3}57 !4 = !{i32 1, !"wchar_size", i32 4}58 !5 = !{i32 7, !"uwtable", i32 2}59 !6 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git 44673278e029d7a6f56c8a3177247026b831720f)"}60 !7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooxx", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)61 !8 = !DISubroutineType(types: !9)62 !9 = !{!10, !10, !10}63 !10 = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed)64 !11 = !{!12, !13, !14, !15}65 !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !10)66 !13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 1, type: !10)67 !14 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 2, type: !10)68 !15 = !DILocalVariable(name: "d", scope: !7, file: !1, line: 3, type: !10)69 !16 = !DILocation(line: 0, scope: !7)70 !17 = !DILocation(line: 2, column: 19, scope: !7)71 !18 = !DILocation(line: 3, column: 23, scope: !7)72 !19 = !DILocation(line: 4, column: 12, scope: !7)73 !20 = !DILocation(line: 4, column: 3, scope: !7)74 75...76---77name: _Z3fooxx78alignment: 1679exposesReturnsTwice: false80legalized: false81regBankSelected: false82selected: false83failedISel: false84tracksRegLiveness: true85hasWinCFI: false86callsEHReturn: false87callsUnwindInit: false88hasEHContTarget: false89hasEHScopes: false90hasEHFunclets: false91failsVerification: false92tracksDebugUserValues: true93debugInstrRef: true94registers: []95liveins:96 - { reg: '$rdi', virtual-reg: '' }97 - { reg: '$rsi', virtual-reg: '' }98frameInfo:99 isFrameAddressTaken: false100 isReturnAddressTaken: false101 hasStackMap: false102 hasPatchPoint: false103 stackSize: 0104 offsetAdjustment: 0105 maxAlignment: 1106 adjustsStack: false107 hasCalls: false108 stackProtector: ''109 functionContext: ''110 maxCallFrameSize: 0111 cvBytesOfCalleeSavedRegisters: 0112 hasOpaqueSPAdjustment: false113 hasVAStart: false114 hasMustTailInVarArgFunc: false115 hasTailCall: false116 localFrameSize: 0117 savePoint: []118 restorePoint: []119fixedStack:120- { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default, 121 callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '', 122 debug-info-expression: '', debug-info-location: '' }123stack: []124callSites: []125debugValueSubstitutions:126 - { srcinst: 1, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }127constants: []128machineFunctionInfo: {}129body: |130 bb.0.entry:131 liveins: $rdi, $rsi132 133 renamable $rax = LEA64r renamable $rsi, 1, renamable $rdi, 0, $noreg, debug-instr-number 3, debug-location !17134 DBG_VALUE $rax, $noreg, !13, !DIExpression(), debug-location !17135 $r15 = MOV64rr killed $rax, debug-location !16136 renamable $rax = LEA64r renamable $rdi, 1, $noreg, 12, $noreg, debug-location !16137 $rax = MOV64rr killed $r15, debug-location !16138 renamable $r15 = LEA64r renamable $rdi, 1, $noreg, 12, $noreg, debug-location !16139 RET64 $r15, debug-location !20140 141...142