1--- | 2 ; RUN: llc %s -mtriple=x86_64 -run-pass=livedebugvalues -o - -experimental-debug-variable-locations | FileCheck %s -implicit-check-not=DBG_VALUE 3 ; 4 ; Test that InstrRefBasedLDV / livedebugvalues doesn't crash when it sees 5 ; illegal instruction referencing debug-info. This can be caused by 6 ; optimisations not updating debug-info or doing it incorrectly, which is 7 ; inevitable. When that happens, we should safely drop the variable location, 8 ; but not crash. 9 10 define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { 11 entry: 12 ret i32 0, !dbg !17 13 } 14 15 !llvm.dbg.cu = !{!0} 16 !llvm.module.flags = !{!7, !8, !9, !10} 17 !llvm.ident = !{!11} 18 !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) 19 !1 = !DIFile(filename: "main.cpp", directory: "F:\") 20 !2 = !{} 21 !3 = !{!4} 22 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) 23 !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) 24 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 25 !7 = !{i32 2, !"Dwarf Version", i32 4} 26 !8 = !{i32 2, !"Debug Info Version", i32 3} 27 !9 = !{i32 1, !"wchar_size", i32 2} 28 !10 = !{i32 7, !"PIC Level", i32 2} 29 !11 = !{!"clang version 10.0.0"} 30 !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) 31 !13 = !DISubroutineType(types: !14) 32 !14 = !{!6, !6} 33 !15 = !{!16} 34 !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) 35 !17 = !DILocation(line: 10, scope: !12) 36 37... 38--- 39name: _Z8bb_to_bb 40debugInstrRef: true 41debugValueSubstitutions: 42 - { srcinst: 4, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 } 43body: | 44 bb.0.entry: 45 successors: %bb.1, %bb.2 46 ; CHECK-LABE: bb.0.entry: 47 48 $rax = MOV64ri 1, debug-instr-number 1, debug-location !17 49 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !17 50 ;; First check that picking out location works as usual. 51 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0) 52 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $rax 53 54 $rax = MOV64ri 1, debug-instr-number 2, debug-location !17 55 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 999), debug-location !17 56 ;; Test out of bounds operand number. 57 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 999) 58 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg 59 60 $rax = MOV64ri 1, debug-instr-number 3, debug-location !17 61 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 1), debug-location !17 62 ;; Test non-register operand 63 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 1) 64 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg 65 66 ;; FIXME: We should test what happens when this meta-instruction is seen 67 ;; by livedbugvalues with an instruction number. However, right now it's 68 ;; impossible to turn the machine-code verifier off when loading MIR? 69 ;KILL implicit killed $eflags, debug-instr-number 4, debug-location !17 70 ;DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(4, 0), debug-location !17 71 ;;; Test non-def operand 72 ;; check: DBG_INSTR_REF {{.+}}, dbg-instr-ref(4, 0) 73 ;; check-next: DBG_VALUE_LIST {{.+}}, $noreg 74 75 $noreg = MOV32ri 1, debug-instr-number 5, debug-location !17 76 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !17 77 ;; Def of $noreg? 78 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0) 79 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg 80 81 JCC_1 %bb.1, 1, implicit $eflags 82 JMP_1 %bb.2 83 84 bb.1: 85 successors: %bb.3 86 ; CHECK-LABEL: bb.1: 87 88 DBG_PHI $rax, 6 89 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(6, 1), debug-location !17 90 ;; Test out-of-bounds reference to a DBG_PHI. 91 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(6, 1) 92 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg 93 94 DBG_PHI $noreg, 7 95 JMP_1 %bb.3 96 97 bb.2: 98 successors: %bb.3 99 ; CHECK-LABEL: bb.2: 100 DBG_PHI 1, 6 101 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(6, 0), debug-location !17 102 ;; Test non-reg operand to DBG_PHI. It's not clear if this can ever happen 103 ;; as the result of an optimisation, but lets test for it anyway. 104 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(6, 0) 105 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg 106 107 DBG_PHI 1, 7 108 JMP_1 %bb.3 109 110 bb.3: 111 ; CHECK-LABEL: bb.3: 112 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(7, 0), debug-location !17 113 ;; PHI resolution of illegal inputs shouldn't crash either. It should also 114 ;; come out as a $noreg location. 115 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(7, 0) 116 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg 117 118 RET 0, debug-location !17 119 120... 121