xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-spillrestore.mir (revision d53425e2a33a0ff7336c86d3f668b1855c47a6de)
1# RUN: llc -mtriple=x86_64-- -run-pass livedebugvalues -o - %s -experimental-debug-variable-locations=false | FileCheck %s --implicit-check-not=DBG_VALUE_LIST
2#
3# A DBG_VALUE_LIST that has a component spilt and restored should had its
4# expression and operands updated to refer to the stack for that period, and
5# then return to normal once the value is restored.
6#
7# CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "c"
8#
9# CHECK-LABEL: bb.0.entry:
10# CHECK:       DBG_VALUE_LIST ![[VAR]],
11# CHECK-SAME:  !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus),
12# CHECK-SAME:  $rdi, $rsi,
13# CHECK:       MOV64mr $rsp, 1, $noreg, -16, $noreg, $rdi
14# CHECK-NEXT:  DBG_VALUE_LIST ![[VAR]],
15# CHECK-SAME:  !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_LLVM_arg, 1, DW_OP_plus),
16# CHECK-SAME:                $rsp, $rsi,
17# CHECK:       $rdi = MOV64rm $rsp, 1, $noreg, -16,
18# CHECK-NEXT:  DBG_VALUE_LIST ![[VAR]],
19# CHECK-SAME:  !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus),
20# CHECK-SAME:  $rdi, $rsi,
21
22--- |
23  ; ModuleID = 'test.cpp'
24  source_filename = "test.cpp"
25  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
26  target triple = "x86_64-unknown-linux-gnu"
27
28  ; Function Attrs: norecurse nounwind readnone uwtable
29  define dso_local i32 @_Z3fooii(i32 %a, i32 %b) local_unnamed_addr !dbg !7 {
30  entry:
31    ret i32 0, !dbg !17
32  }
33
34  ; Function Attrs: nounwind readnone speculatable willreturn
35  declare void @llvm.dbg.value(metadata, metadata, metadata)
36
37  !llvm.dbg.cu = !{!0}
38  !llvm.module.flags = !{!3, !4, !5}
39  !llvm.ident = !{!6}
40
41  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
42  !1 = !DIFile(filename: "test.cpp", directory: "/")
43  !2 = !{}
44  !3 = !{i32 7, !"Dwarf Version", i32 4}
45  !4 = !{i32 2, !"Debug Info Version", i32 3}
46  !5 = !{i32 1, !"wchar_size", i32 4}
47  !6 = !{!"clang version 11.0.0"}
48  !7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooii", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
49  !8 = !DISubroutineType(types: !9)
50  !9 = !{!10, !10, !10}
51  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
52  !11 = !{!12, !13, !14}
53  !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10)
54  !13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 2, type: !10)
55  !14 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 3, type: !10)
56  !15 = !DILocation(line: 0, scope: !7)
57  !16 = !DILocation(line: 4, column: 12, scope: !7)
58  !17 = !DILocation(line: 4, column: 3, scope: !7)
59
60...
61---
62name:            _Z3fooii
63stack:
64  - { id: 0, offset: -16, size: 8, alignment: 8, type: spill-slot }
65body:             |
66  bb.0.entry:
67    liveins: $rdi, $rsi
68
69    $rsp = frame-setup SUB64ri8 $rsp, 24, implicit-def dead $eflags
70    DBG_VALUE_LIST !14, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $rsi, debug-location !15
71    MOV64mr $rsp, 1, _, -16, _, $rdi, debug-location !15 :: (store (s64) into %stack.0)
72    $rax = COPY killed $rdi
73    $rdi = MOV64ri 0
74    $rdi = MOV64rm $rsp, 1, $noreg, -16, $noreg, debug-location !15 :: (load (s64) from %stack.0)
75    RET64
76...
77
78