1--- | 2 ; RUN: llc %s -mtriple=x86_64 -run-pass=livedebugvalues -o - -force-instr-ref-livedebugvalues=1 -emulate-old-livedebugvalues=0 | FileCheck %s -implicit-check-not=DBG_VALUE 3 4 ;; When using instruction referencing LiveDebugValues, when a register gets 5 ;; clobbered, we should transfer variable locations to backup locations, if 6 ;; one is available. 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. 10 11 declare i32 @use() local_unnamed_addr; 12 13 define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { 14 entry: 15 br label %bb1, !dbg !17 16 bb1: 17 br label %bb2, !dbg !17 18 bb2: 19 br label %bb3, !dbg !17 20 bb3: 21 br label %bb3, !dbg !17 22 bb4: 23 br label %bb3, !dbg !17 24 bb5: 25 ret i32 0, !dbg !17 26 } 27 28 !llvm.dbg.cu = !{!0} 29 !llvm.module.flags = !{!7, !8, !9, !10} 30 !llvm.ident = !{!11} 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:\") 33 !2 = !{} 34 !3 = !{!4} 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) 45 !14 = !{!6, !6} 46 !15 = !{!16} 47 !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) 48 !17 = !DILocation(line: 10, scope: !12) 49 50... 51--- 52name: _Z8bb_to_bb 53debugInstrRef: true 54stack: 55 - { id: 0, type: spill-slot, offset: -12, size: 4, alignment: 4 } 56body: | 57 bb.0.entry: 58 $eax = MOV32ri 0, debug-location !17 59 $eax = COPY $ebx 60 DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 61 ;; Over-write eax, we should recover its location as being in ebx. 62 $eax = MOV32ri 0, debug-location !17 63 64 ; CHECK: DBG_VALUE $eax 65 ; CHECK-NEXT: $eax = MOV32ri 0 66 ; CHECK-NEXT: DBG_VALUE $ebx 67 68 ;; The same should occur for spills. 69 $ebx = MOV32ri 2, debug-location !17 70 MOV32mr $rsp, 1, _, -12, _, killed $ebx :: (store 4 into %stack.0) 71 DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 72 $ebx = MOV32ri 0, debug-location !17 73 74 ; CHECK-NEXT: $ebx = MOV32ri 2 75 ; CHECK-NEXT: MOV32mr $rsp 76 ; CHECK-NEXT: DBG_VALUE $ebx 77 ; CHECK-NEXT: $ebx = MOV32ri 78 ; CHECK-NEXT: DBG_VALUE $rsp 79 80 ;; Try re-loading the variable value from the stack; we shouldn't issue a 81 ;; DBG_VALUE to follow it, the stack locations are usually longer lived and 82 ;; this reduces location list entropy. Then, clobber the stack location, 83 ;; and check that we can relocate the variable to being in the loaded 84 ;; register. 85 $ebx = MOV32rm $rsp, 1, _, -12, _ :: (load 4 from %stack.0) 86 MOV32mr $rsp, 1, _, -12, _, killed $esi :: (store 4 into %stack.0) 87 ; CHECK: $ebx = MOV32rm 88 ; CHECK-NEXT: MOV32mr $rsp 89 ; CHECK-NEXT: DBG_VALUE $ebx 90 91 ;; Now test copies and register masks. 92 $eax = COPY $ebx 93 DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 94 ;; Overwrite ebx with a copy. 95 $ecx = MOV32ri 1, debug-location !17 96 $ebx = COPY $ecx 97 98 ; CHECK: DBG_VALUE $ebx 99 ; CHECK-NEXT: $ecx = MOV32ri 100 ; CHECK-NEXT: $ebx = COPY 101 ; CHECK-NEXT: DBG_VALUE $eax 102 103 ;; Similarly, with a register mask 104 $ebx = COPY $eax 105 CALL64pcrel32 @use, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, debug-location !17 106 107 ; CHECK-NEXT: $ebx = COPY $eax 108 ; CHECK-NEXT: CALL64pcrel32 109 ; CHECK-NEXT: DBG_VALUE $ebx 110 111 RET64 $eax, debug-location !17 112... 113