121 lines · plain
1--- |2 ; RUN: llc %s -mtriple=x86_64 -run-pass=livedebugvalues -o - -experimental-debug-variable-locations | FileCheck %s -implicit-check-not=DBG_VALUE3 ;4 ; Test that InstrRefBasedLDV / livedebugvalues doesn't crash when it sees5 ; illegal instruction referencing debug-info. This can be caused by6 ; optimisations not updating debug-info or doing it incorrectly, which is7 ; 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 !1713 }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_bb40debugInstrRef: true41debugValueSubstitutions:42 - { srcinst: 4, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }43body: |44 bb.0.entry:45 successors: %bb.1, %bb.246 ; CHECK-LABE: bb.0.entry:47 48 $rax = MOV64ri 1, debug-instr-number 1, debug-location !1749 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !1750 ;; 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 {{.+}}, $rax53 54 $rax = MOV64ri 1, debug-instr-number 2, debug-location !1755 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 999), debug-location !1756 ;; Test out of bounds operand number.57 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 999)58 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg59 60 $rax = MOV64ri 1, debug-instr-number 3, debug-location !1761 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 1), debug-location !1762 ;; Test non-register operand63 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 1)64 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg65 66 ;; FIXME: We should test what happens when this meta-instruction is seen67 ;; by livedbugvalues with an instruction number. However, right now it's68 ;; impossible to turn the machine-code verifier off when loading MIR?69 ;KILL implicit killed $eflags, debug-instr-number 4, debug-location !1770 ;DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(4, 0), debug-location !1771 ;;; Test non-def operand72 ;; check: DBG_INSTR_REF {{.+}}, dbg-instr-ref(4, 0)73 ;; check-next: DBG_VALUE_LIST {{.+}}, $noreg74 75 $noreg = MOV32ri 1, debug-instr-number 5, debug-location !1776 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(5, 0), debug-location !1777 ;; Def of $noreg?78 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(5, 0)79 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg80 81 JCC_1 %bb.1, 1, implicit $eflags82 JMP_1 %bb.283 84 bb.1:85 successors: %bb.386 ; CHECK-LABEL: bb.1:87 88 DBG_PHI $rax, 689 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(6, 1), debug-location !1790 ;; 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 {{.+}}, $noreg93 94 DBG_PHI $noreg, 795 JMP_1 %bb.396 97 bb.2:98 successors: %bb.399 ; CHECK-LABEL: bb.2:100 DBG_PHI 1, 6101 DBG_INSTR_REF !16, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(6, 0), debug-location !17102 ;; Test non-reg operand to DBG_PHI. It's not clear if this can ever happen103 ;; 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 {{.+}}, $noreg106 107 DBG_PHI 1, 7108 JMP_1 %bb.3109 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 !17113 ;; PHI resolution of illegal inputs shouldn't crash either. It should also114 ;; come out as a $noreg location.115 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(7, 0)116 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $noreg117 118 RET 0, debug-location !17119 120...121