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