1 # RUN: llc --run-pass=livedebugvalues %s -o - -experimental-debug-variable-locations | FileCheck %s --check-prefixes=CHECK
3 # Test that we accurately track variables through transfers and clobbers.
5 # In this test case, the value of "b" is found in $rax. From there it is moved
6 # 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 with
8 # DBG_VALUEs pointing to $rax, then $r15, then $rax again.
10 # CHECK-LABEL: bb.0.entry:
11 # CHECK: DBG_VALUE $rax,
12 # CHECK: $r15 = MOV64rr
14 ## Technically it's correct to insert the DBG_VALUE for $r15 either immediately
15 ## after the move to $r15 or immediately after $rax is clobbered, but no later.
16 # CHECK: DBG_VALUE $r15,
17 # CHECK: $rax = LEA64r
18 # CHECK: $rax = MOV64rr
20 ## Again, the DBG_VALUE can come either after the copy to $rax or the kill of
21 ## $r15, but no later.
22 # CHECK: $r15 = LEA64r
23 # CHECK: DBG_VALUE $rax,
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"
32 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
33 define dso_local noundef i64 @_Z3fooxx(i64 noundef %a, i64 noundef %b) local_unnamed_addr !dbg !7 {
35 call void @llvm.dbg.value(metadata i64 %a, metadata !12, metadata !DIExpression()), !dbg !16
36 call void @llvm.dbg.value(metadata i64 %b, metadata !13, metadata !DIExpression()), !dbg !16
37 %add = add nsw i64 %b, %a, !dbg !17
38 call void @llvm.dbg.value(metadata i64 %add, metadata !14, metadata !DIExpression()), !dbg !16
39 %mul17 = sub i64 %a, %b, !dbg !18
40 %sub = mul i64 %add, %mul17, !dbg !18
41 call void @llvm.dbg.value(metadata i64 %sub, metadata !15, metadata !DIExpression()), !dbg !16
42 %add2 = add nsw i64 %sub, %add, !dbg !19
43 ret i64 %add2, !dbg !20
46 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
47 declare void @llvm.dbg.value(metadata, metadata, metadata)
50 !llvm.module.flags = !{!2, !3, !4, !5}
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)
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)
79 exposesReturnsTwice: false
81 regBankSelected: false
84 tracksRegLiveness: true
87 callsUnwindInit: false
91 failsVerification: false
92 tracksDebugUserValues: true
96 - { reg: '$rdi', virtual-reg: '' }
97 - { reg: '$rsi', virtual-reg: '' }
99 isFrameAddressTaken: false
100 isReturnAddressTaken: false
111 cvBytesOfCalleeSavedRegisters: 0
112 hasOpaqueSPAdjustment: false
114 hasMustTailInVarArgFunc: false
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: '' }
125 debugValueSubstitutions:
126 - { srcinst: 1, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }
128 machineFunctionInfo: {}
133 renamable $rax = LEA64r renamable $rsi, 1, renamable $rdi, 0, $noreg, debug-instr-number 3, debug-location !17
134 DBG_VALUE $rax, $noreg, !13, !DIExpression(), debug-location !17
135 $r15 = MOV64rr killed $rax, debug-location !16
136 renamable $rax = LEA64r renamable $rdi, 1, $noreg, 12, $noreg, debug-location !16
137 $rax = MOV64rr killed $r15, debug-location !16
138 renamable $r15 = LEA64r renamable $rdi, 1, $noreg, 12, $noreg, debug-location !16
139 RET64 $r15, debug-location !20