1--- | 2 ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - -experimental-debug-variable-locations | FileCheck %s -implicit-check-not=DBG_VALUE 3 4 define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { 5 entry: 6 ret i32 0, !dbg !17 7 } 8 9 !llvm.dbg.cu = !{!0} 10 !llvm.module.flags = !{!7, !8, !9, !10} 11 !llvm.ident = !{!11} 12 !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) 13 !1 = !DIFile(filename: "main.cpp", directory: "F:\") 14 !2 = !{} 15 !3 = !{!4} 16 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) 17 !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) 18 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 19 !7 = !{i32 2, !"Dwarf Version", i32 4} 20 !8 = !{i32 2, !"Debug Info Version", i32 3} 21 !9 = !{i32 1, !"wchar_size", i32 2} 22 !10 = !{i32 7, !"PIC Level", i32 2} 23 !11 = !{!"clang version 10.0.0"} 24 !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) 25 !13 = !DISubroutineType(types: !14) 26 !14 = !{!6, !6} 27 !15 = !{!16} 28 !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) 29 !17 = !DILocation(line: 10, scope: !12) 30 31... 32--- 33name: _Z8bb_to_bb 34debugValueSubstitutions: 35 - { srcinst: 4, srcop: 0, dstinst: 3, dstop: 0 } 36body: | 37 bb.0.entry: 38 $rax = MOV64ri 1, debug-instr-number 1, debug-location !17 39 ; This debug instruction should identify the value as being in $rax. 40 DBG_INSTR_REF 1, 0, !16, !DIExpression(), debug-location !17 41 ; CHECK: DBG_VALUE $rax, $noreg 42 43 $rbx = COPY killed $rax, debug-location !17 44 $rax = MOV64ri 1, debug-location !17 45 ; Presently, this COPY isn't followed. Dealing with that is future work. 46 47 DBG_INSTR_REF 2, 0, !16, !DIExpression(), debug-location !17 48 ; No instruction is labelled with the number "2". This should produce an 49 ; empty variable location. 50 ; CHECK: DBG_VALUE $noreg, $noreg 51 52 $rbx = MOV64ri 1, debug-instr-number 3, debug-location !17 53 JMP_1 %bb.1 54 55 56 ; CHECK-LABEL: bb.1: 57 bb.1: 58 59 DBG_INSTR_REF 3, 0, !16, !DIExpression(), debug-location !17 60 ; This refers to a value def'd in a parent block -- but it should be 61 ; tracked into this block. 62 ; CHECK: DBG_VALUE $rbx, $noreg 63 JMP_1 %bb.2 64 65 ; CHECK-LABEL: bb.2: 66 bb.2: 67 ; Just like any other variable location, live-ins should be created for 68 ; any successor blocks. 69 ; CHECK: DBG_VALUE $rbx, $noreg 70 71 DBG_INSTR_REF 5, 0, !16, !DIExpression(), debug-location !17 72 ; This is a debug use-before-def: the value appears a few instructions 73 ; later. Any earlier value should be terminated here, _and_ we should 74 ; emit a DBG_VALUE when the value becomes available. 75 ; CHECK: DBG_VALUE $noreg, $noreg 76 77 $rax = MOV64ri 1, debug-location !17 78 $rax = MOV64ri 1, debug-location !17 79 $rcx = MOV64ri 1, debug-instr-number 5, debug-location !17 80 ; CHECK: DBG_VALUE $rcx, $noreg 81 $rax = MOV64ri 1, debug-location !17 82 83 DBG_INSTR_REF 6, 0, !16, !DIExpression(), debug-location !17 84 ; Another debug use-before-def, but across block boundaries. 85 ; CHECK: DBG_VALUE $noreg, $noreg 86 JMP_1 %bb.3 87 88 ; CHECK-LABEL: bb.3: 89 bb.3: 90 $rax = MOV64ri 1, debug-location !17 91 $rdx = MOV64ri 1, debug-instr-number 6, debug-location !17 92 ; CHECK: DBG_VALUE $rdx, $noreg 93 94 ; Terminate variable location for next few blocks, 95 DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17 96 ; CHECK: DBG_VALUE $noreg, $noreg 97 JMP_1 %bb.4 98 99 bb.4: 100 ; The next three blocks form a debug use-before-def modelling a scenario 101 ; where an instruction is sunk (debug inst in bb5, value in bb6). However, 102 ; because a different path joins bb.6, we should _not_ add any DBG_VALUE. 103 ; A different variable value may enter the block via the other path. 104 $rdx = MOV64ri 1, implicit-def $eflags, debug-location !17 105 JCC_1 %bb.6, 4, implicit $eflags, debug-location !17 106 bb.5: 107 DBG_INSTR_REF 7, 0, !16, !DIExpression(), debug-location !17 108 ; CHECK: DBG_VALUE $noreg, $noreg 109 JMP_1 %bb.6, debug-location !17 110 bb.6: 111 $rsi = MOV64ri 1, debug-instr-number 7, debug-location !17 112 JMP_1 %bb.7, debug-location !17 113 114 ; A use-before-def shouldn't pass another definition of the variable location 115 ; or value. 116 bb.7: 117 DBG_INSTR_REF 8, 0, !16, !DIExpression(), debug-location !17 118 ; CHECK: DBG_VALUE $noreg, $noreg 119 DBG_VALUE $rax, $noreg, !16, !DIExpression(), debug-location !17 120 ; CHECK: DBG_VALUE $rax, $noreg, 121 $rdi = MOV64ri 1, debug-instr-number 8, debug-location !17 122 123 ; Loops: use-before-defs should be live-through loops, assuming that nothing 124 ; in that loop modifies the variable location. 125 bb.8: 126 DBG_INSTR_REF 9, 0, !16, !DIExpression(), debug-location !17 127 ; CHECK: DBG_VALUE $noreg, $noreg 128 JCC_1 %bb.8, 4, implicit $eflags 129 bb.9: 130 $rax = MOV64ri 11, debug-instr-number 9, debug-location !17 131 ; CHECK: DBG_VALUE $rax, $noreg, 132 133 ; Likewise, use-before-defs where anything changes the variable location 134 ; or value in the loop, should be discarded. 135 bb.10: 136 ; live-in, 137 ; CHECK: DBG_VALUE $rax, $noreg, 138 DBG_INSTR_REF 10, 0, !16, !DIExpression(), debug-location !17 139 ; CHECK: DBG_VALUE $noreg, $noreg 140 141 bb.11: 142 $rbx = MOV64ri 1, debug-location !17 143 144 bb.12: 145 DBG_INSTR_REF 9, 0, !16, !DIExpression(), debug-location !17 146 ; This still has a value in $rax, 147 ; CHECK: DBG_VALUE $rax, $noreg 148 JCC_1 %bb.11, 4, implicit $eflags 149 150 bb.13: 151 ; Live in, 152 ; CHECK: DBG_VALUE $rax, $noreg 153 $rbx = MOV64ri 11, debug-instr-number 10, debug-location !17 154 ; This is instruction 10 referred to in bb.10. However, as the variable 155 ; location/value has been modified in the meantime, no DBG_VALUE should be 156 ; generated here. 157 RETQ $eax, debug-location !17 158... 159