|
| 1 | +# RUN: llc --run-pass=livedebugvalues -o - %s | FileCheck %s --implicit-check-not=DBG_VALUE |
| 2 | +# REQUIRES: x86-registered-target |
| 3 | + |
| 4 | +# This test covers the scenario where a DBG_VALUE created prior to LiveDebugValues has an entry-value expression. |
| 5 | +# It ensures that a clobbered stack copy doesn't crash if used as an entry-value because entry-values can't be clobbered. |
| 6 | + |
| 7 | +--- | |
| 8 | + target triple = "x86_64-" |
| 9 | + |
| 10 | + define i32 @baz(i32 swiftasync %arg1, i32 noundef %arg2, i1 %cond) !dbg !9 { |
| 11 | + tail call void @llvm.dbg.value(metadata i32 %arg1, metadata !17, metadata !DIExpression(DW_OP_LLVM_entry_value, 1)), !dbg !19 |
| 12 | + br i1 %cond, label %if.then, label %if.else, !dbg !22 |
| 13 | + if.then: |
| 14 | + %call = call i32 @foo(i32 noundef %arg1), !dbg !23 |
| 15 | + br label %if.end, !dbg !25 |
| 16 | + if.else: |
| 17 | + %call1 = call i32 @foo(i32 noundef %arg2), !dbg !26 |
| 18 | + br label %if.end |
| 19 | + if.end: |
| 20 | + %temp.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ], !dbg !28 |
| 21 | + ret i32 %temp.0, !dbg !29 |
| 22 | + } |
| 23 | + |
| 24 | + declare i32 @foo(i32) |
| 25 | + declare void @llvm.dbg.value(metadata, metadata, metadata) |
| 26 | + |
| 27 | + !llvm.dbg.cu = !{!0} |
| 28 | + !llvm.module.flags = !{!2, !3} |
| 29 | + |
| 30 | + !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "ha", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 31 | + !1 = !DIFile(filename: "test.c", directory: "hah") |
| 32 | + !2 = !{i32 7, !"Dwarf Version", i32 4} |
| 33 | + !3 = !{i32 2, !"Debug Info Version", i32 3} |
| 34 | + !9 = distinct !DISubprogram(name: "baz", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, unit: !0, retainedNodes: !13) |
| 35 | + !10 = !DISubroutineType(types: !11) |
| 36 | + !11 = !{!12, !12, !12, !12} |
| 37 | + !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 38 | + !13 = !{!14, !15, !16, !17} |
| 39 | + !14 = !DILocalVariable(name: "arg1", arg: 1, scope: !9, file: !1, line: 3, type: !12) |
| 40 | + !15 = !DILocalVariable(name: "arg2", arg: 2, scope: !9, file: !1, line: 3, type: !12) |
| 41 | + !16 = !DILocalVariable(name: "cond", arg: 3, scope: !9, file: !1, line: 3, type: !12) |
| 42 | + !17 = !DILocalVariable(name: "local", scope: !9, file: !1, line: 4, type: !12) |
| 43 | + !19 = !DILocation(line: 0, scope: !9) |
| 44 | + !20 = !DILocation(line: 7, column: 7, scope: !21) |
| 45 | + !21 = distinct !DILexicalBlock(scope: !9, file: !1, line: 7, column: 7) |
| 46 | + !22 = !DILocation(line: 7, column: 7, scope: !9) |
| 47 | + !23 = !DILocation(line: 8, column: 12, scope: !24) |
| 48 | + !24 = distinct !DILexicalBlock(scope: !21, file: !1, line: 7, column: 13) |
| 49 | + !25 = !DILocation(line: 9, column: 3, scope: !24) |
| 50 | + !26 = !DILocation(line: 10, column: 12, scope: !27) |
| 51 | + !27 = distinct !DILexicalBlock(scope: !21, file: !1, line: 9, column: 10) |
| 52 | + !28 = !DILocation(line: 0, scope: !21) |
| 53 | + !29 = !DILocation(line: 13, column: 3, scope: !9) |
| 54 | + |
| 55 | +... |
| 56 | +--- |
| 57 | +name: baz |
| 58 | +alignment: 16 |
| 59 | +debugInstrRef: true |
| 60 | +tracksDebugUserValues: true |
| 61 | +liveins: |
| 62 | + - { reg: '$r14', virtual-reg: '' } |
| 63 | + - { reg: '$edi', virtual-reg: '' } |
| 64 | + - { reg: '$esi', virtual-reg: '' } |
| 65 | + - { reg: '$edx', virtual-reg: '' } |
| 66 | +body: | |
| 67 | + bb.0: |
| 68 | + successors: %bb.2(0x40000000), %bb.1(0x40000000) |
| 69 | + liveins: $r14, $edi, $edx, $esi |
| 70 | + DBG_VALUE $r14, $noreg, !14, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !19 |
| 71 | + CMP32ri killed renamable $edx, 0, implicit-def $eflags, debug-location !20 |
| 72 | + JCC_1 %bb.2, 4, implicit killed $eflags, debug-location !22 |
| 73 | + bb.1.if.then: |
| 74 | + successors: %bb.3(0x80000000) |
| 75 | + liveins: $edi, $r13 |
| 76 | + CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $eax, debug-location !23 |
| 77 | + $r14 = MOV64ri 0, debug-location !20 |
| 78 | + JMP_1 %bb.3, debug-location !25 |
| 79 | + bb.2.if.else: |
| 80 | + successors: %bb.3(0x80000000) |
| 81 | + liveins: $esi, $r13 |
| 82 | + $edi = MOV32rr killed $esi, debug-location !26 |
| 83 | + CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $eax, debug-location !26 |
| 84 | + bb.3.if.end: |
| 85 | + liveins: $eax |
| 86 | + $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !29 |
| 87 | + RET64 implicit $eax, debug-location !29 |
| 88 | +# CHECK-LABEL: bb.0: |
| 89 | +# CHECK: DBG_VALUE $r14, {{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1) |
| 90 | +# CHECK-LABEL: bb.1.if.then: |
| 91 | +# CHECK: DBG_VALUE $r14, {{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1) |
| 92 | +# CHECK-NEXT: CALL64pcrel32 @foo |
| 93 | +# CHECK-NEXT: $r14 = MOV64ri 0 |
| 94 | +# CHECK-NOT: DBG_VALUE $r14, {{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1) |
| 95 | +# CHECK-LABEL: bb.2.if.else: |
| 96 | +# CHECK: DBG_VALUE $r14, {{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1) |
| 97 | +# CHECK-LABEL: bb.3.if.end: |
| 98 | +# CHECK: DBG_VALUE $r14, {{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1) |
0 commit comments