2 ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - -force-instr-ref-livedebugvalues=1 -emulate-old-livedebugvalues=0 | FileCheck %s -implicit-check-not=DBG_VALUE
4 ;; When using instruction referencing LiveDebugValues, when a register gets
5 ;; clobbered, we should transfer variable locations to backup locations, if
7 ;; I've written this test in terms of DBG_VALUEs rather than DBG_INSTR_REFs
8 ;; as this is purely a LiveDebugValues feature, and should work without the
9 ;; need to use any other instructoin referencing work.
11 declare i32 @use() local_unnamed_addr;
13 define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 {
15 br label %bb1, !dbg !17
17 br label %bb2, !dbg !17
19 br label %bb3, !dbg !17
21 br label %bb3, !dbg !17
23 br label %bb3, !dbg !17
29 !llvm.module.flags = !{!7, !8, !9, !10}
31 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None)
32 !1 = !DIFile(filename: "main.cpp", directory: "F:\")
35 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
36 !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
37 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
38 !7 = !{i32 2, !"Dwarf Version", i32 4}
39 !8 = !{i32 2, !"Debug Info Version", i32 3}
40 !9 = !{i32 1, !"wchar_size", i32 2}
41 !10 = !{i32 7, !"PIC Level", i32 2}
42 !11 = !{!"clang version 10.0.0"}
43 !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
44 !13 = !DISubroutineType(types: !14)
47 !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
48 !17 = !DILocation(line: 10, scope: !12)
54 - { id: 0, type: spill-slot, offset: -12, size: 4, alignment: 4 }
57 $eax = MOV32ri 0, debug-location !17
59 DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17
60 ;; Over-write eax, we should recover its location as being in ebx.
61 $eax = MOV32ri 0, debug-location !17
63 ; CHECK: DBG_VALUE $eax
64 ; CHECK-NEXT: $eax = MOV32ri 0
65 ; CHECK-NEXT: DBG_VALUE $ebx
67 ;; The same should occur for spills.
68 $ebx = MOV32ri 2, debug-location !17
69 MOV32mr $rsp, 1, _, -12, _, killed $ebx :: (store 4 into %stack.0)
70 DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
71 $ebx = MOV32ri 0, debug-location !17
73 ; CHECK-NEXT: $ebx = MOV32ri 2
74 ; CHECK-NEXT: MOV32mr $rsp
75 ; CHECK-NEXT: DBG_VALUE $ebx
76 ; CHECK-NEXT: $ebx = MOV32ri
77 ; CHECK-NEXT: DBG_VALUE $rsp
79 ;; Try re-loading the variable value from the stack; we shouldn't issue a
80 ;; DBG_VALUE to follow it, the stack locations are usually longer lived and
81 ;; this reduces location list entropy. Then, clobber the stack location,
82 ;; and check that we can relocate the variable to being in the loaded
84 $ebx = MOV32rm $rsp, 1, _, -12, _ :: (load 4 from %stack.0)
85 MOV32mr $rsp, 1, _, -12, _, killed $esi :: (store 4 into %stack.0)
86 ; CHECK: $ebx = MOV32rm
87 ; CHECK-NEXT: MOV32mr $rsp
88 ; CHECK-NEXT: DBG_VALUE $ebx
90 ;; Now test copies and register masks.
92 DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
93 ;; Overwrite ebx with a copy.
94 $ecx = MOV32ri 1, debug-location !17
97 ; CHECK: DBG_VALUE $ebx
98 ; CHECK-NEXT: $ecx = MOV32ri
99 ; CHECK-NEXT: $ebx = COPY
100 ; CHECK-NEXT: DBG_VALUE $eax
102 ;; Similarly, with a register mask
104 CALL64pcrel32 @use, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, debug-location !17
106 ; CHECK-NEXT: $ebx = COPY $eax
107 ; CHECK-NEXT: CALL64pcrel32
108 ; CHECK-NEXT: DBG_VALUE $ebx
110 RET64 $eax, debug-location !17