xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-movements.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# The MIR below moves values from argument registers to callee saved registers,
4# moves that are followed by DBG_VALUEs and which should also result in
5# DBG_VALUE_LISTs moving their operands.
6#
7# CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "c"
8#
9# CHECK-LABEL: bb.0.entry:
10# CHECK:       DBG_VALUE_LIST ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0,
11# CHECK-SAME:                        DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $rsi
12# CHECK:       $rbx = COPY killed $rdi
13# CHECK-NEXT:  DBG_VALUE_LIST ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0,
14# CHECK-SAME:                        DW_OP_LLVM_arg, 1, DW_OP_plus), $rbx, $rsi
15# CHECK-LABEL: bb.1:
16# CHECK:       DBG_VALUE_LIST ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0,
17# CHECK-SAME:                        DW_OP_LLVM_arg, 1, DW_OP_plus), $rbx, $rsi
18# CHECK:       $rbp = COPY killed $rsi
19# CHECK-NEXT:  DBG_VALUE_LIST ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0,
20# CHECK-SAME:                        DW_OP_LLVM_arg, 1, DW_OP_plus), $rbx, $rbp
21# CHECK-LABEL: bb.2:
22# CHECK:       DBG_VALUE_LIST ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0,
23# CHECK-SAME:                        DW_OP_LLVM_arg, 1, DW_OP_plus), $rbx, $rbp
24--- |
25  ; ModuleID = 'test.cpp'
26  source_filename = "test.cpp"
27  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
28  target triple = "x86_64-unknown-linux-gnu"
29
30  ; Function Attrs: norecurse nounwind readnone uwtable
31  define dso_local i32 @_Z3fooii(i32 %a, i32 %b) local_unnamed_addr !dbg !7 {
32  entry:
33    ret i32 0, !dbg !17
34  }
35
36  ; Function Attrs: nounwind readnone speculatable willreturn
37  declare void @llvm.dbg.value(metadata, metadata, metadata)
38
39  !llvm.dbg.cu = !{!0}
40  !llvm.module.flags = !{!3, !4, !5}
41  !llvm.ident = !{!6}
42
43  !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)
44  !1 = !DIFile(filename: "test.cpp", directory: "/")
45  !2 = !{}
46  !3 = !{i32 7, !"Dwarf Version", i32 4}
47  !4 = !{i32 2, !"Debug Info Version", i32 3}
48  !5 = !{i32 1, !"wchar_size", i32 4}
49  !6 = !{!"clang version 11.0.0"}
50  !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)
51  !8 = !DISubroutineType(types: !9)
52  !9 = !{!10, !10, !10}
53  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
54  !11 = !{!12, !13, !14}
55  !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10)
56  !13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 2, type: !10)
57  !14 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 3, type: !10)
58  !15 = !DILocation(line: 0, scope: !7)
59  !16 = !DILocation(line: 4, column: 12, scope: !7)
60  !17 = !DILocation(line: 4, column: 3, scope: !7)
61
62...
63---
64name:            _Z3fooii
65fixedStack:
66  - { id: 0, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
67      callee-saved-register: '$rbx', callee-saved-restored: true }
68  - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
69      callee-saved-register: '$rbp', callee-saved-restored: true }
70body:             |
71  bb.0.entry:
72    liveins: $rdi, $rsi
73
74    DBG_VALUE_LIST !14, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $rsi, debug-location !15
75    $rbx = COPY killed $rdi
76    $rdi = MOV64ri 0
77    JMP_1 %bb.1
78
79  bb.1:
80    liveins: $rbx, $rsi
81    $rbp = COPY killed $rsi
82    $rsi = MOV64ri 0
83    JMP_1 %bb.2
84
85  bb.2:
86    liveins: $rbx, $rbp
87    RET64 $rbp, debug-location !17
88
89...
90
91