xref: /llvm-project/llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_stackslot_subregs.mir (revision 40a4cbb0f200e5e0bafbd58d55c2da6daab9515d)
1# RUN: llc %s -mtriple=x86_64 -run-pass=livedebugvalues -experimental-debug-variable-locations -o - 2>&1 | FileCheck %s
2#
3# Test that we can spill and restore through subregisters too. In this test,
4# eax is def'd and then spilt, but as part of a larger register.
5--- |
6  define i8 @test(i32 %bar) local_unnamed_addr !dbg !7 {
7  entry:
8    ret i8 0, !dbg !12
9  }
10
11  declare dso_local void @ext(i64)
12
13  !llvm.dbg.cu = !{!0}
14  !llvm.module.flags = !{!3, !4, !5, !6}
15  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
16  !1 = !DIFile(filename: "foo.cpp", directory: ".")
17  !2 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_signed)
18  !3 = !{i32 2, !"Dwarf Version", i32 4}
19  !4 = !{i32 2, !"Debug Info Version", i32 3}
20  !5 = !{i32 1, !"wchar_size", i32 2}
21  !6 = !{i32 7, !"PIC Level", i32 2}
22  !7 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
23  !8 = !DISubroutineType(types: !9)
24  !9 = !{!2, !2}
25  !10 = !{!11}
26  !11 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 7, type: !2)
27  !12 = !DILocation(line: 10, scope: !7)
28...
29---
30name: test
31tracksRegLiveness: true
32debugInstrRef: true
33liveins:
34  - { reg: '$rdi', virtual-reg: '' }
35stack:
36  - { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
37      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
38      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
39body:  |
40  bb.0:
41  liveins: $rdi, $rax, $rbx
42    $eax = MOV32ri 0, debug-instr-number 1
43    $edi = COPY $eax
44    MOV64mr $rsp, 1, $noreg, 16, $noreg, $rdi :: (store 8 into %stack.0)
45    $rsi = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)
46
47    ; Store a random value onto stack, forces value to be in one place only.
48    ; Clobber other registers that contain the value we're to track.
49    MOV64mr $rsp, 1, $noreg, 16, $noreg, $rbx :: (store 8 into %stack.0)
50    $rax = MOV64ri 0
51    $rdi = MOV64ri 0
52
53    DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !12
54    ; CHECK:      DBG_INSTR_REF
55    ; CHECK-NEXT: DBG_VALUE_LIST {{.+}}, $esi
56    RET64 $rsi, debug-location !12
57...
58