1 # RUN: llc %s -o - -mtriple=x86_64-unknown-unknown \
2 # RUN: -experimental-debug-variable-locations -run-pass=livedebugvalues\
5 # Test that a DBG_INSTR_REF that refers to a DBG_PHI, will be translated into a
6 # DBG_VALUE of the value read at that DBG_PHI -- in this test, when the value
10 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
11 target triple = "x86_64-unknown-linux-gnu"
13 define dso_local i32 @foo(i64 %bar, i64 %baz) !dbg !7 {
17 declare dso_local void @ext(i64)
19 declare dso_local i64 @getlong()
22 !llvm.module.flags = !{!3, !4, !5}
25 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
26 !1 = !DIFile(filename: "test.c", directory: "/tmp/out.c")
28 !3 = !{i32 7, !"Dwarf Version", i32 4}
29 !4 = !{i32 2, !"Debug Info Version", i32 3}
30 !5 = !{i32 1, !"wchar_size", i32 4}
32 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
33 !8 = !DISubroutineType(types: !9)
35 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
36 !11 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
37 !12 = !DILocalVariable(name: "bar", arg: 1, scope: !7, file: !1, line: 3, type: !11)
38 !13 = !DILocation(line: 0, scope: !7)
39 !14 = !DILocalVariable(name: "baz", arg: 2, scope: !7, file: !1, line: 3, type: !11)
40 !19 = distinct !DILexicalBlock(scope: !7, file: !1, line: 8, column: 7)
41 !26 = !DILocation(line: 13, column: 3, scope: !7)
47 tracksRegLiveness: true
59 cvBytesOfCalleeSavedRegisters: 16
61 - { id: 0, type: spill-slot, offset: -24, size: 8, alignment: 8, callee-saved-register: '$rbx' }
62 - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$r14' }
63 machineFunctionInfo: {}
65 - { id: 0, name: '', type: spill-slot, offset: 0, size: 8, alignment: 8,
66 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
67 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
71 liveins: $rdi, $rsi, $r14, $rbx
77 MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax :: (store 8 into %stack.0)
80 ;; A DBG_PHI of the stack should resolve to the stack location.
81 DBG_PHI %stack.0, 1, 64
83 ;; Reload value, clobber stack location.
84 $rcx = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)
85 MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax :: (store 8 into %stack.0)
87 ;; This should resolve to the loaded register.
88 DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !13
\r
89 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
\r
90 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}} $rcx
\r
92 ;; And if we say it's a smaller size, we should be able to pick out smaller
93 ;; subregisters within the stack slot.
94 DBG_PHI %stack.0, 2, 32
96 $rcx = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)
97 MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax :: (store 8 into %stack.0)
99 ;; This should pick out the 32 bit value.
100 DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !13
\r
101 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 0)
\r
102 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}} $ecx
\r
104 ;; Try all the other subregs.
105 DBG_PHI %stack.0, 3, 16
107 $rcx = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)
108 MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax :: (store 8 into %stack.0)
110 DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 0), debug-location !13
\r
111 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 0)
\r
112 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}} $cx
\r
114 DBG_PHI %stack.0, 4, 8
116 $rcx = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load 8 from %stack.0)
117 MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax :: (store 8 into %stack.0)
119 DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(4, 0), debug-location !13
\r
120 ; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(4, 0)
\r
121 ; CHECK-NEXT: DBG_VALUE_LIST {{.+}} $cl
\r
123 ;; We can't, at this time, describe subregister fields with nonzero offset.
124 ;; It's easily achieved by attaching more data to stack DBG_PHIs, but it's
125 ;; not clear that LLVM will ever merge registers to generate such locations.
127 RET64 implicit $eax, debug-location !26