xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir (revision 40a4cbb0f200e5e0bafbd58d55c2da6daab9515d)
1# RUN: llc -run-pass livedebugvalues -mtriple=x86_64 -o - %s \
2# RUN:  -experimental-debug-variable-locations=true | FileCheck %s
3
4# Generated from the following source with:
5# clang -g -mllvm -stop-before=livedebugvalues -S -O2 test.c -o test.mir
6# Then more functions added to test for extra behaviours with complex
7# expressions:
8#   'g': test for a crash from PR42773
9#   'h': complex expressions should be restored
10#   'i': spills should be restored across block boundaries
11#   'j': indirect DBG_VALUEs should be indirect after restoration
12#   'k': variadic debug values should be restored
13
14# #define FORCE_SPILL() \
15#   __asm volatile("" : : : \
16#                    "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", \
17#                    "r9", "r10", "r11", "r12", "r13", "r14", "r15")
18# int f(int *p) {
19#   if (p) {
20#     FORCE_SPILL();
21#   }
22#   return *(p + 1);
23# }
24
25# Pick out DILocalVariable numbers for "p", "q" and "r" etc
26# CHECK: ![[PVAR:[0-9]+]] = !DILocalVariable(name: "p",
27# CHECK: ![[QVAR:[0-9]+]] = !DILocalVariable(name: "q",
28# CHECK: ![[RVAR:[0-9]+]] = !DILocalVariable(name: "r",
29# CHECK: ![[SVAR:[0-9]+]] = !DILocalVariable(name: "s",
30# CHECK: ![[TVAR:[0-9]+]] = !DILocalVariable(name: "t",
31# CHECK: ![[UVAR:[0-9]+]] = !DILocalVariable(name: "u",
32
33# Ascertain that the spill has been recognized and manifested in a DBG_VALUE.
34# CHECK: MOV64mr $rsp,{{.*-8.*}}killed{{.*}}$rdi :: (store (s64) into %stack.0)
35# CHECK-NEXT: DBG_VALUE $rsp,{{.*}}![[PVAR]],{{.*}}!DIExpression(DW_OP_constu, 8, DW_OP_minus)
36
37# Check for the restore.
38# CHECK: $rdi = MOV64rm $rsp,{{.*-8.*}}:: (load (s64) from %stack.0)
39# CHECK-NEXT: $rax = MOV64ri 0
40# CHECK-NEXT: MOV64mr
41# CHECK-NEXT: DBG_VALUE $rdi,{{.*}}![[PVAR]], !DIExpression()
42
43--- |
44  define dso_local i32 @f(ptr readonly %p) local_unnamed_addr !dbg !7 {
45  entry:
46    call void @llvm.dbg.value(metadata ptr %p, metadata !13, metadata !DIExpression()), !dbg !14
47    %tobool = icmp eq ptr %p, null, !dbg !15
48    br i1 %tobool, label %if.end, label %if.then, !dbg !17
49
50  if.then:                                          ; preds = %entry
51    tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !18, !srcloc !20
52    br label %if.end, !dbg !21
53
54  if.end:                                           ; preds = %entry, %if.then
55    %add.ptr = getelementptr inbounds i32, ptr %p, i64 1, !dbg !22
56    %0 = load i32, ptr %add.ptr, align 4, !dbg !23, !tbaa !24
57    ret i32 %0, !dbg !28
58  }
59
60  define dso_local i32 @g(ptr readonly %p) local_unnamed_addr !dbg !107 {
61  entry:
62    call void @llvm.dbg.value(metadata ptr %p, metadata !113, metadata !DIExpression()), !dbg !114
63    %tobool = icmp eq ptr %p, null, !dbg !115
64    br i1 %tobool, label %if.end, label %if.then, !dbg !117
65
66  if.then:                                          ; preds = %entry
67    tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !118, !srcloc !120
68    br label %if.end, !dbg !121
69
70  if.end:                                           ; preds = %entry, %if.then
71    %add.ptr = getelementptr inbounds i32, ptr %p, i64 1, !dbg !122
72    %0 = load i32, ptr %add.ptr, align 4, !dbg !123, !tbaa !24
73    ret i32 %0, !dbg !128
74  }
75
76  define dso_local i32 @h(ptr readonly %p) local_unnamed_addr !dbg !207 {
77  entry:
78    call void @llvm.dbg.value(metadata ptr %p, metadata !213, metadata !DIExpression()), !dbg !214
79    %tobool = icmp eq ptr %p, null, !dbg !215
80    br i1 %tobool, label %if.end, label %if.then, !dbg !217
81
82  if.then:                                          ; preds = %entry
83    tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !218, !srcloc !220
84    br label %if.end, !dbg !221
85
86  if.end:                                           ; preds = %entry, %if.then
87    %add.ptr = getelementptr inbounds i32, ptr %p, i64 1, !dbg !222
88    %0 = load i32, ptr %add.ptr, align 4, !dbg !223, !tbaa !24
89    ret i32 %0, !dbg !228
90  }
91
92  define dso_local i32 @i(ptr readonly %p) local_unnamed_addr !dbg !307 {
93  entry:
94    br label %foo
95
96  foo:
97    call void @llvm.dbg.value(metadata ptr %p, metadata !313, metadata !DIExpression()), !dbg !314
98    %tobool = icmp eq ptr %p, null, !dbg !315
99    br i1 %tobool, label %if.end, label %if.then, !dbg !317
100
101  if.then:                                          ; preds = %entry
102    tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !318, !srcloc !320
103    br label %if.end, !dbg !321
104
105  if.end:                                           ; preds = %entry, %if.then
106    %add.ptr = getelementptr inbounds i32, ptr %p, i64 1, !dbg !322
107    %0 = load i32, ptr %add.ptr, align 4, !dbg !323, !tbaa !24
108    ret i32 %0, !dbg !328
109  }
110
111  define dso_local i32 @j(ptr readonly %p) local_unnamed_addr !dbg !402 {
112  entry:
113    br label %foo
114
115  foo:
116    call void @llvm.dbg.value(metadata ptr %p, metadata !404, metadata !DIExpression()), !dbg !405
117    %tobool = icmp eq ptr %p, null, !dbg !406
118    br i1 %tobool, label %if.end, label %if.then, !dbg !408
119
120  if.then:                                          ; preds = %entry
121    tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !409, !srcloc !411
122    br label %if.end, !dbg !412
123
124  if.end:                                           ; preds = %entry, %if.then
125    %add.ptr = getelementptr inbounds i32, ptr %p, i64 1, !dbg !413
126    %0 = load i32, ptr %add.ptr, align 4, !dbg !414, !tbaa !24
127    ret i32 %0, !dbg !415
128  }
129
130  define dso_local i32 @k(ptr readonly %p) local_unnamed_addr !dbg !507 {
131  entry:
132    call void @llvm.dbg.value(metadata ptr %p, metadata !513, metadata !DIExpression()), !dbg !514
133    %tobool = icmp eq ptr %p, null, !dbg !515
134    br i1 %tobool, label %if.end, label %if.then, !dbg !517
135
136  if.then:                                          ; preds = %entry
137    tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !518, !srcloc !520
138    br label %if.end, !dbg !521
139
140  if.end:                                           ; preds = %entry, %if.then
141    %add.ptr = getelementptr inbounds i32, ptr %p, i64 1, !dbg !522
142    %0 = load i32, ptr %add.ptr, align 4, !dbg !523, !tbaa !24
143    ret i32 %0, !dbg !528
144  }
145
146  declare void @llvm.dbg.value(metadata, metadata, metadata)
147
148  !llvm.dbg.cu = !{!0}
149  !llvm.module.flags = !{!3, !4, !5}
150  !llvm.ident = !{!6}
151
152  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (https://git.llvm.org/git/clang.git/ 57a6ce7ac318de98e3e777e09cb9ed8282b5cc03) (https://git.llvm.org/git/llvm.git/ ff54a19e4912d7f15cb02798a7f2048441bff751)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
153  !1 = !DIFile(filename: "test2.c", directory: "/home/test")
154  !2 = !{}
155  !3 = !{i32 2, !"Dwarf Version", i32 4}
156  !4 = !{i32 2, !"Debug Info Version", i32 3}
157  !5 = !{i32 1, !"wchar_size", i32 4}
158  !6 = !{!"clang version 9.0.0 (https://git.llvm.org/git/clang.git/ 57a6ce7ac318de98e3e777e09cb9ed8282b5cc03) (https://git.llvm.org/git/llvm.git/ ff54a19e4912d7f15cb02798a7f2048441bff751)"}
159  !7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
160  !8 = !DISubroutineType(types: !9)
161  !9 = !{!10, !11}
162  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
163  !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
164  !12 = !{!13}
165  !13 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 5, type: !11)
166  !14 = !DILocation(line: 5, column: 12, scope: !7)
167  !15 = !DILocation(line: 6, column: 7, scope: !16)
168  !16 = distinct !DILexicalBlock(scope: !7, file: !1, line: 6, column: 7)
169  !17 = !DILocation(line: 6, column: 7, scope: !7)
170  !18 = !DILocation(line: 7, column: 5, scope: !19)
171  !19 = distinct !DILexicalBlock(scope: !16, file: !1, line: 6, column: 10)
172  !20 = !{i32 -2147471544}
173  !21 = !DILocation(line: 8, column: 3, scope: !19)
174  !22 = !DILocation(line: 9, column: 14, scope: !7)
175  !23 = !DILocation(line: 9, column: 10, scope: !7)
176  !24 = !{!25, !25, i64 0}
177  !25 = !{!"int", !26, i64 0}
178  !26 = !{!"omnipotent char", !27, i64 0}
179  !27 = !{!"Simple C/C++ TBAA"}
180  !28 = !DILocation(line: 9, column: 3, scope: !7)
181  !29 = !DILocalVariable(name: "p0", scope: !7, file: !1, line: 5, type: !11)
182  !101 = !DIBasicType(name: "looong int", size: 64, encoding: DW_ATE_signed)
183  !107 = distinct !DISubprogram(name: "g", scope: !0, file: !1, line: 105, type: !8, scopeLine: 105, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !112)
184  !112 = !{!113}
185  !113 = !DILocalVariable(name: "q", arg: 1, scope: !107, file: !1, line: 105, type: !101)
186  !114 = !DILocation(line: 105, column: 12, scope: !107)
187  !115 = !DILocation(line: 106, column: 7, scope: !116)
188  !116 = distinct !DILexicalBlock(scope: !107, file: !1, line: 106, column: 7)
189  !117 = !DILocation(line: 106, column: 7, scope: !107)
190  !118 = !DILocation(line: 107, column: 5, scope: !119)
191  !119 = distinct !DILexicalBlock(scope: !116, file: !1, line: 106, column: 10)
192  !120 = !{i32 -2147471544}
193  !121 = !DILocation(line: 108, column: 3, scope: !119)
194  !122 = !DILocation(line: 109, column: 14, scope: !107)
195  !123 = !DILocation(line: 109, column: 10, scope: !107)
196  !128 = !DILocation(line: 109, column: 3, scope: !107)
197  !201 = !DIBasicType(name: "looong int", size: 64, encoding: DW_ATE_signed)
198  !207 = distinct !DISubprogram(name: "g", scope: !0, file: !1, line: 105, type: !8, scopeLine: 105, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !212)
199  !212 = !{!213}
200  !213 = !DILocalVariable(name: "r", arg: 1, scope: !207, file: !1, line: 105, type: !201)
201  !214 = !DILocation(line: 105, column: 12, scope: !207)
202  !215 = !DILocation(line: 106, column: 7, scope: !216)
203  !216 = distinct !DILexicalBlock(scope: !207, file: !1, line: 106, column: 7)
204  !217 = !DILocation(line: 106, column: 7, scope: !207)
205  !218 = !DILocation(line: 107, column: 5, scope: !219)
206  !219 = distinct !DILexicalBlock(scope: !216, file: !1, line: 106, column: 10)
207  !220 = !{i32 -2147471544}
208  !221 = !DILocation(line: 108, column: 3, scope: !219)
209  !222 = !DILocation(line: 109, column: 14, scope: !207)
210  !223 = !DILocation(line: 109, column: 10, scope: !207)
211  !228 = !DILocation(line: 109, column: 3, scope: !207)
212  !301 = !DIBasicType(name: "looong int", size: 64, encoding: DW_ATE_signed)
213  !307 = distinct !DISubprogram(name: "g", scope: !0, file: !1, line: 105, type: !8, scopeLine: 105, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !312)
214  !312 = !{!313}
215  !313 = !DILocalVariable(name: "s", arg: 1, scope: !307, file: !1, line: 105, type: !301)
216  !314 = !DILocation(line: 105, column: 12, scope: !307)
217  !315 = !DILocation(line: 106, column: 7, scope: !316)
218  !316 = distinct !DILexicalBlock(scope: !307, file: !1, line: 106, column: 7)
219  !317 = !DILocation(line: 106, column: 7, scope: !307)
220  !318 = !DILocation(line: 107, column: 5, scope: !319)
221  !319 = distinct !DILexicalBlock(scope: !316, file: !1, line: 106, column: 10)
222  !320 = !{i32 -2147471544}
223  !321 = !DILocation(line: 108, column: 3, scope: !319)
224  !322 = !DILocation(line: 109, column: 14, scope: !307)
225  !323 = !DILocation(line: 109, column: 10, scope: !307)
226  !328 = !DILocation(line: 109, column: 3, scope: !307)
227  !401 = !DIBasicType(name: "looong int", size: 64, encoding: DW_ATE_signed)
228  !402 = distinct !DISubprogram(name: "j", scope: !0, file: !1, line: 105, type: !8, scopeLine: 105, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !403)
229  !403 = !{!404}
230  !404 = !DILocalVariable(name: "t", arg: 1, scope: !402, file: !1, line: 105, type: !401)
231  !405 = !DILocation(line: 105, column: 12, scope: !402)
232  !406 = !DILocation(line: 106, column: 7, scope: !407)
233  !407 = distinct !DILexicalBlock(scope: !402, file: !1, line: 106, column: 7)
234  !408 = !DILocation(line: 106, column: 7, scope: !402)
235  !409 = !DILocation(line: 107, column: 5, scope: !410)
236  !410 = distinct !DILexicalBlock(scope: !407, file: !1, line: 106, column: 10)
237  !411 = !{i32 -2147471544}
238  !412 = !DILocation(line: 108, column: 3, scope: !410)
239  !413 = !DILocation(line: 109, column: 14, scope: !402)
240  !414 = !DILocation(line: 109, column: 10, scope: !402)
241  !415 = !DILocation(line: 109, column: 3, scope: !402)
242  !501 = !DIBasicType(name: "looong int", size: 64, encoding: DW_ATE_signed)
243  !507 = distinct !DISubprogram(name: "k", scope: !0, file: !1, line: 105, type: !8, scopeLine: 105, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !512)
244  !512 = !{!513}
245  !513 = !DILocalVariable(name: "u", arg: 1, scope: !507, file: !1, line: 105, type: !501)
246  !514 = !DILocation(line: 105, column: 12, scope: !507)
247  !515 = !DILocation(line: 106, column: 7, scope: !516)
248  !516 = distinct !DILexicalBlock(scope: !507, file: !1, line: 106, column: 7)
249  !517 = !DILocation(line: 106, column: 7, scope: !507)
250  !518 = !DILocation(line: 107, column: 5, scope: !519)
251  !519 = distinct !DILexicalBlock(scope: !516, file: !1, line: 106, column: 10)
252  !520 = !{i32 -2147471544}
253  !521 = !DILocation(line: 108, column: 3, scope: !519)
254  !522 = !DILocation(line: 109, column: 14, scope: !507)
255  !523 = !DILocation(line: 109, column: 10, scope: !507)
256  !528 = !DILocation(line: 109, column: 3, scope: !507)
257
258...
259---
260name:            f
261alignment:       16
262exposesReturnsTwice: false
263legalized:       false
264regBankSelected: false
265selected:        false
266failedISel:      false
267tracksRegLiveness: true
268debugInstrRef: true
269hasWinCFI:       false
270registers:       []
271liveins:
272  - { reg: '$rdi', virtual-reg: '' }
273frameInfo:
274  isFrameAddressTaken: false
275  isReturnAddressTaken: false
276  hasStackMap:     false
277  hasPatchPoint:   false
278  stackSize:       48
279  offsetAdjustment: -48
280  maxAlignment:    8
281  adjustsStack:    false
282  hasCalls:        false
283  stackProtector:  ''
284  maxCallFrameSize: 0
285  cvBytesOfCalleeSavedRegisters: 48
286  hasOpaqueSPAdjustment: false
287  hasVAStart:      false
288  hasMustTailInVarArgFunc: false
289  localFrameSize:  0
290  savePoint:       ''
291  restorePoint:    ''
292fixedStack:
293  - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: default,
294      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
295      debug-info-expression: '', debug-info-location: '' }
296  - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,
297      callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '',
298      debug-info-expression: '', debug-info-location: '' }
299  - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,
300      callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '',
301      debug-info-expression: '', debug-info-location: '' }
302  - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
303      callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '',
304      debug-info-expression: '', debug-info-location: '' }
305  - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
306      callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '',
307      debug-info-expression: '', debug-info-location: '' }
308  - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
309      callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
310      debug-info-expression: '', debug-info-location: '' }
311stack:
312  - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
313      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
314      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
315constants:       []
316body:             |
317  bb.0.entry:
318    successors: %bb.2(0x30000000), %bb.1(0x50000000)
319    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
320
321    DBG_VALUE $rdi, $noreg, !13, !DIExpression(), debug-location !14
322    DBG_VALUE $rdi, $noreg, !13, !DIExpression(), debug-location !14
323    TEST64rr renamable $rdi, renamable $rdi, implicit-def $eflags, debug-location !15
324    JCC_1 %bb.2, 4, implicit $eflags, debug-location !17
325
326  bb.1.if.then:
327    successors: %bb.2(0x80000000)
328    liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx
329
330    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
331    CFI_INSTRUCTION def_cfa_offset 16
332    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
333    CFI_INSTRUCTION def_cfa_offset 24
334    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
335    CFI_INSTRUCTION def_cfa_offset 32
336    frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
337    CFI_INSTRUCTION def_cfa_offset 40
338    frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
339    CFI_INSTRUCTION def_cfa_offset 48
340    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
341    CFI_INSTRUCTION def_cfa_offset 56
342    CFI_INSTRUCTION offset $rbx, -56
343    CFI_INSTRUCTION offset $r12, -48
344    CFI_INSTRUCTION offset $r13, -40
345    CFI_INSTRUCTION offset $r14, -32
346    CFI_INSTRUCTION offset $r15, -24
347    CFI_INSTRUCTION offset $rbp, -16
348    MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0)
349    INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !20, debug-location !18
350    renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)
351    ; Clobber stack location to force variable location to move to $rdi.
352    $rax = MOV64ri 0
353    MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0)
354    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
355    CFI_INSTRUCTION def_cfa_offset 48
356    $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
357    CFI_INSTRUCTION def_cfa_offset 40
358    $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
359    CFI_INSTRUCTION def_cfa_offset 32
360    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
361    CFI_INSTRUCTION def_cfa_offset 24
362    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
363    CFI_INSTRUCTION def_cfa_offset 16
364    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
365    CFI_INSTRUCTION def_cfa_offset 8
366
367  bb.2.if.end:
368    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
369
370    renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !23 :: (load (s32) from %ir.add.ptr, !tbaa !24)
371    RET64 $eax, debug-location !28
372
373...
374---
375# This second function has been appended as a regression test against a
376# crash, caused by expressions being created from spill restores that did
377# not preserve fragment information. Test that no empty expressions are
378# created at all, and the last block describes both variable fragments.
379
380# CHECK-LABEL: name: g
381# CHECK-NOT: !DIExpression()
382# CHECK-LABEL: bb.2.if.end:
383# CHECK:       DBG_VALUE $rbx, $noreg, ![[QVAR]], !DIExpression(DW_OP_LLVM_fragment, 32, 32)
384# CHECK:       DBG_VALUE $rdi, $noreg, ![[QVAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 32)
385
386name:            g
387alignment:       16
388tracksRegLiveness: true
389debugInstrRef: true
390liveins:
391  - { reg: '$rdi', virtual-reg: '' }
392frameInfo:
393  stackSize:       48
394  offsetAdjustment: -48
395  maxAlignment:    8
396  cvBytesOfCalleeSavedRegisters: 48
397  localFrameSize:  0
398fixedStack:
399  - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: default,
400      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
401      debug-info-expression: '', debug-info-location: '' }
402  - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,
403      callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '',
404      debug-info-expression: '', debug-info-location: '' }
405  - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,
406      callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '',
407      debug-info-expression: '', debug-info-location: '' }
408  - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
409      callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '',
410      debug-info-expression: '', debug-info-location: '' }
411  - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
412      callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '',
413      debug-info-expression: '', debug-info-location: '' }
414  - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
415      callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
416      debug-info-expression: '', debug-info-location: '' }
417stack:
418  - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
419      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
420      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
421constants:       []
422body:             |
423  bb.0.entry:
424    successors: %bb.1(0x50000000)
425    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
426
427    DBG_VALUE $rdi, $noreg, !113, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !114
428    TEST64rr renamable $rdi, renamable $rdi, implicit-def $eflags, debug-location !115
429    JMP_1 %bb.1, implicit $eflags, debug-location !117
430
431  bb.1.if.then:
432    successors: %bb.2(0x80000000)
433    liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx
434
435    MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0)
436    renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)
437
438  bb.2.if.end:
439    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
440
441    DBG_VALUE $rbx, $noreg, !113, !DIExpression(DW_OP_LLVM_fragment, 32, 32), debug-location !114
442    MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rbx :: (store (s64) into %stack.0)
443    renamable $rsi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)
444
445    renamable $eax = MOV32rm killed renamable $rsi, 1, $noreg, 4, $noreg, debug-location !123 :: (load (s32) from %ir.add.ptr, !tbaa !24)
446    $rdi = MOV64ri 0
447    RET64 $eax, debug-location !128
448
449...
450---
451# This third function tests that complex expressions are spilt, and restored
452# correctly within a basic block.
453
454# CHECK-LABEL: name: h
455# CHECK-LABEL: bb.0.entry:
456# CHECK:       DBG_VALUE $rdi, $noreg, ![[RVAR]], !DIExpression(DW_OP_plus_uconst, 1)
457# CHECK-LABEL: bb.1.if.then:
458# CHECK:       DBG_VALUE $rdi, $noreg, ![[RVAR]], !DIExpression(DW_OP_plus_uconst, 1)
459# CHECK:       DBG_VALUE $rsp, $noreg, ![[RVAR]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_plus_uconst, 1)
460# CHECK:       DBG_VALUE $rdi, $noreg, ![[RVAR]], !DIExpression(DW_OP_plus_uconst, 1)
461# CHECK-LABEL: bb.2.if.end:
462# CHECK:       DBG_VALUE $rdi, $noreg, ![[RVAR]], !DIExpression(DW_OP_plus_uconst, 1)
463
464name:            h
465alignment:       16
466tracksRegLiveness: true
467debugInstrRef: true
468liveins:
469  - { reg: '$rdi', virtual-reg: '' }
470frameInfo:
471  stackSize:       48
472  offsetAdjustment: -48
473  maxAlignment:    8
474  cvBytesOfCalleeSavedRegisters: 48
475  localFrameSize:  0
476fixedStack:
477  - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: default,
478      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
479      debug-info-expression: '', debug-info-location: '' }
480  - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,
481      callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '',
482      debug-info-expression: '', debug-info-location: '' }
483  - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,
484      callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '',
485      debug-info-expression: '', debug-info-location: '' }
486  - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
487      callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '',
488      debug-info-expression: '', debug-info-location: '' }
489  - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
490      callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '',
491      debug-info-expression: '', debug-info-location: '' }
492  - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
493      callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
494      debug-info-expression: '', debug-info-location: '' }
495stack:
496  - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
497      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
498      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
499constants:       []
500body:             |
501  bb.0.entry:
502    successors: %bb.2(0x30000000), %bb.1(0x50000000)
503    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
504
505    DBG_VALUE $rdi, $noreg, !213, !DIExpression(DW_OP_plus_uconst, 1), debug-location !214
506    TEST64rr renamable $rdi, renamable $rdi, implicit-def $eflags, debug-location !215
507    JCC_1 %bb.2, 4, implicit $eflags, debug-location !217
508
509  bb.1.if.then:
510    successors: %bb.2(0x80000000)
511    liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx
512
513    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
514    CFI_INSTRUCTION def_cfa_offset 16
515    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
516    CFI_INSTRUCTION def_cfa_offset 24
517    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
518    CFI_INSTRUCTION def_cfa_offset 32
519    frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
520    CFI_INSTRUCTION def_cfa_offset 40
521    frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
522    CFI_INSTRUCTION def_cfa_offset 48
523    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
524    CFI_INSTRUCTION def_cfa_offset 56
525    CFI_INSTRUCTION offset $rbx, -56
526    CFI_INSTRUCTION offset $r12, -48
527    CFI_INSTRUCTION offset $r13, -40
528    CFI_INSTRUCTION offset $r14, -32
529    CFI_INSTRUCTION offset $r15, -24
530    CFI_INSTRUCTION offset $rbp, -16
531    MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0)
532    INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !220, debug-location !218
533    renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)
534    ; Clobber stack location to force variable location to move to $rdi.
535    $rax = MOV64ri 0
536    MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0)
537    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
538    CFI_INSTRUCTION def_cfa_offset 48
539    $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
540    CFI_INSTRUCTION def_cfa_offset 40
541    $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
542    CFI_INSTRUCTION def_cfa_offset 32
543    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
544    CFI_INSTRUCTION def_cfa_offset 24
545    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
546    CFI_INSTRUCTION def_cfa_offset 16
547    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
548    CFI_INSTRUCTION def_cfa_offset 8
549
550  bb.2.if.end:
551    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
552
553    renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !223 :: (load (s32) from %ir.add.ptr, !tbaa !24)
554    RET64 $eax, debug-location !228
555
556
557
558...
559---
560# Function four: test that spill restores are detected across block
561# boundaries. The spill has been moved to bb.1, children of which are
562# bb 2 and 3, neither of which modifies the stack loc. The exit block (3)
563# should still be tracking the spill, and restore it on stack load.
564
565# Summary: loc is in $rdi in bb0, spills to stack in bb1, remains in stack
566# in bb2, starts in stack then loaded in bb3.
567
568# CHECK-LABEL: name: i
569# CHECK-LABEL: bb.0.entry:
570# CHECK:       DBG_VALUE $rdi, $noreg, ![[SVAR]], !DIExpression(DW_OP_plus_uconst, 1)
571# CHECK-LABEL: bb.1.foo:
572# CHECK:       DBG_VALUE $rdi, $noreg, ![[SVAR]], !DIExpression(DW_OP_plus_uconst, 1)
573# CHECK:       DBG_VALUE $rsp, $noreg, ![[SVAR]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_plus_uconst, 1)
574# CHECK-LABEL: bb.2.if.then:
575# CHECK:       DBG_VALUE $rsp, $noreg, ![[SVAR]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_plus_uconst, 1)
576# CHECK-LABEL: bb.3.if.end
577# CHECK:       DBG_VALUE $rsp, $noreg, ![[SVAR]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_plus_uconst, 1)
578# CHECK:       DBG_VALUE $rdi, $noreg, ![[SVAR]], !DIExpression(DW_OP_plus_uconst, 1)
579name:            i
580alignment:       16
581tracksRegLiveness: true
582debugInstrRef: true
583liveins:
584  - { reg: '$rdi', virtual-reg: '' }
585frameInfo:
586  stackSize:       48
587  offsetAdjustment: -48
588  maxAlignment:    8
589  cvBytesOfCalleeSavedRegisters: 48
590  localFrameSize:  0
591fixedStack:
592  - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: default,
593      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
594      debug-info-expression: '', debug-info-location: '' }
595  - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,
596      callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '',
597      debug-info-expression: '', debug-info-location: '' }
598  - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,
599      callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '',
600      debug-info-expression: '', debug-info-location: '' }
601  - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
602      callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '',
603      debug-info-expression: '', debug-info-location: '' }
604  - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
605      callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '',
606      debug-info-expression: '', debug-info-location: '' }
607  - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
608      callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
609      debug-info-expression: '', debug-info-location: '' }
610stack:
611  - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
612      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
613      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
614constants:       []
615body:             |
616  bb.0.entry:
617    successors: %bb.1
618    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
619
620    DBG_VALUE $rdi, $noreg, !313, !DIExpression(DW_OP_plus_uconst, 1), debug-location !314
621    JMP_1 %bb.1, debug-location !317
622
623  bb.1.foo:
624    successors: %bb.3(0x30000000), %bb.2(0x50000000)
625    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
626
627    $rax = COPY $rdi
628    MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0)
629    $rdi = MOV64ri 0
630    TEST64rr $rax, renamable $rax, implicit-def $eflags, debug-location !315
631    JCC_1 %bb.3, 4, implicit $eflags, debug-location !317
632
633  bb.2.if.then:
634    successors: %bb.3(0x80000000)
635    liveins: $rbp, $r15, $r14, $r13, $r12, $rbx
636
637    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
638    CFI_INSTRUCTION def_cfa_offset 16
639    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
640    CFI_INSTRUCTION def_cfa_offset 24
641    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
642    CFI_INSTRUCTION def_cfa_offset 32
643    frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
644    CFI_INSTRUCTION def_cfa_offset 40
645    frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
646    CFI_INSTRUCTION def_cfa_offset 48
647    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
648    CFI_INSTRUCTION def_cfa_offset 56
649    CFI_INSTRUCTION offset $rbx, -56
650    CFI_INSTRUCTION offset $r12, -48
651    CFI_INSTRUCTION offset $r13, -40
652    CFI_INSTRUCTION offset $r14, -32
653    CFI_INSTRUCTION offset $r15, -24
654    CFI_INSTRUCTION offset $rbp, -16
655    INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !320, debug-location !318
656    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
657    CFI_INSTRUCTION def_cfa_offset 48
658    $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
659    CFI_INSTRUCTION def_cfa_offset 40
660    $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
661    CFI_INSTRUCTION def_cfa_offset 32
662    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
663    CFI_INSTRUCTION def_cfa_offset 24
664    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
665    CFI_INSTRUCTION def_cfa_offset 16
666    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
667    CFI_INSTRUCTION def_cfa_offset 8
668
669  bb.3.if.end:
670    liveins: $rbx, $r12, $r13, $r14, $r15, $rbp
671
672    renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)
673    ; Clobber stack location to force variable location to move to $rdi.
674    $rax = MOV64ri 0
675    MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0)
676    renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !323 :: (load (s32) from %ir.add.ptr, !tbaa !24)
677    RET64 $eax, debug-location !328
678
679...
680---
681# Test that if an unspilt DBG_VALUE starts as an indirect DBG_VALUE, then it
682# is restored as an indirect DBG_VALUE. FIXME: Note that for the intervening
683# period of being a spilt location there is still a missing layer of
684# indirection.
685
686# CHECK-LABEL: name: j
687# CHECK-LABEL: bb.0.entry:
688# CHECK:       DBG_VALUE $rdi, 0, ![[TVAR]], !DIExpression()
689# CHECK-LABEL: bb.1.if.then:
690# CHECK:       DBG_VALUE $rsp, 0, ![[TVAR]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref)
691# CHECK:       INLINEASM
692# CHECK:       DBG_VALUE ${{[a-zA-Z0-9]+}}, 0, ![[TVAR]], !DIExpression()
693# CHECK-LABEL: bb.2.if.end
694
695name:            j
696tracksRegLiveness: true
697debugInstrRef: true
698liveins:
699  - { reg: '$rdi', virtual-reg: '' }
700frameInfo:
701  stackSize:       48
702  offsetAdjustment: -48
703  maxAlignment:    8
704  cvBytesOfCalleeSavedRegisters: 48
705fixedStack:
706  - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: default,
707      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
708      debug-info-expression: '', debug-info-location: '' }
709  - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,
710      callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '',
711      debug-info-expression: '', debug-info-location: '' }
712  - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,
713      callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '',
714      debug-info-expression: '', debug-info-location: '' }
715  - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
716      callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '',
717      debug-info-expression: '', debug-info-location: '' }
718  - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
719      callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '',
720      debug-info-expression: '', debug-info-location: '' }
721  - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
722      callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
723      debug-info-expression: '', debug-info-location: '' }
724stack:
725  - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
726      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
727      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
728constants:       []
729body:             |
730  bb.0.entry:
731    successors: %bb.2, %bb.1
732    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
733
734    DBG_VALUE $rdi, 0, !404, !DIExpression(), debug-location !405
735    DBG_VALUE $rdi, 0, !404, !DIExpression(), debug-location !405
736    TEST64rr renamable $rdi, renamable $rdi, implicit-def $eflags, debug-location !406
737    JCC_1 %bb.2, 4, implicit $eflags, debug-location !408
738
739  bb.1.if.then:
740    successors: %bb.2
741    liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx
742
743    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
744    CFI_INSTRUCTION def_cfa_offset 16
745    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
746    CFI_INSTRUCTION def_cfa_offset 24
747    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
748    CFI_INSTRUCTION def_cfa_offset 32
749    frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
750    CFI_INSTRUCTION def_cfa_offset 40
751    frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
752    CFI_INSTRUCTION def_cfa_offset 48
753    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
754    CFI_INSTRUCTION def_cfa_offset 56
755    CFI_INSTRUCTION offset $rbx, -56
756    CFI_INSTRUCTION offset $r12, -48
757    CFI_INSTRUCTION offset $r13, -40
758    CFI_INSTRUCTION offset $r14, -32
759    CFI_INSTRUCTION offset $r15, -24
760    CFI_INSTRUCTION offset $rbp, -16
761    MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0)
762    INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !20, debug-location !409
763    renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)
764    ; Clobber stack location to force variable location to move to $rdi.
765    $rax = MOV64ri 0
766    MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0)
767    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
768    CFI_INSTRUCTION def_cfa_offset 48
769    $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
770    CFI_INSTRUCTION def_cfa_offset 40
771    $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
772    CFI_INSTRUCTION def_cfa_offset 32
773    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
774    CFI_INSTRUCTION def_cfa_offset 24
775    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
776    CFI_INSTRUCTION def_cfa_offset 16
777    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
778    CFI_INSTRUCTION def_cfa_offset 8
779
780  bb.2.if.end:
781    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
782
783    renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !414 :: (load (s32) from %ir.add.ptr, !tbaa !24)
784    RET64 $eax, debug-location !415
785
786...
787---
788# Test that if the values used by a variable with a variadic debug value are
789# spilt and restored, we correctly track each value individually.
790# This third function tests that complex expressions are spilt, and restored
791# correctly within a basic block.
792
793# CHECK-LABEL: name: k
794# CHECK-LABEL: bb.0.entry:
795# CHECK:       DBG_VALUE_LIST ![[UVAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $r10
796# CHECK-LABEL: bb.1.if.then:
797# CHECK:       DBG_VALUE_LIST ![[UVAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $r10
798# CHECK:       DBG_VALUE_LIST ![[UVAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_plus), $rsp, $r10
799# CHECK:       DBG_VALUE_LIST ![[UVAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_constu, 16, DW_OP_minus, DW_OP_deref, DW_OP_plus), $rsp, $rsp
800# CHECK:       DBG_VALUE_LIST ![[UVAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_constu, 16, DW_OP_minus, DW_OP_deref, DW_OP_plus), $rdi, $rsp
801# CHECK:       DBG_VALUE_LIST ![[UVAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $r10
802# CHECK-LABEL: bb.2.if.end:
803# CHECK:       DBG_VALUE_LIST ![[UVAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $r10
804
805name:            k
806alignment:       16
807tracksRegLiveness: true
808debugInstrRef: true
809liveins:
810  - { reg: '$rdi', virtual-reg: '' }
811  - { reg: '$r10', virtual-reg: '' }
812frameInfo:
813  stackSize:       48
814  offsetAdjustment: -48
815  maxAlignment:    8
816  cvBytesOfCalleeSavedRegisters: 48
817  localFrameSize:  0
818fixedStack:
819  - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: default,
820      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
821      debug-info-expression: '', debug-info-location: '' }
822  - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,
823      callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '',
824      debug-info-expression: '', debug-info-location: '' }
825  - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,
826      callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '',
827      debug-info-expression: '', debug-info-location: '' }
828  - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,
829      callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '',
830      debug-info-expression: '', debug-info-location: '' }
831  - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
832      callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '',
833      debug-info-expression: '', debug-info-location: '' }
834  - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
835      callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
836      debug-info-expression: '', debug-info-location: '' }
837stack:
838  - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
839      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
840      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
841  - { id: 1, name: '', type: spill-slot, offset: -72, size: 8, alignment: 8,
842      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
843      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
844constants:       []
845body:             |
846  bb.0.entry:
847    successors: %bb.2(0x30000000), %bb.1(0x50000000)
848    liveins: $rdi, $r10, $rbx, $r12, $r13, $r14, $r15, $rbp
849
850    DBG_VALUE_LIST !513, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 1, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $r10, debug-location !514
851    TEST64rr renamable $rdi, renamable $rdi, implicit-def $eflags, debug-location !515
852    JCC_1 %bb.2, 4, implicit $eflags, debug-location !517
853
854  bb.1.if.then:
855    successors: %bb.2(0x80000000)
856    liveins: $rdi, $r10, $rbp, $r15, $r14, $r13, $r12, $rbx
857
858    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
859    CFI_INSTRUCTION def_cfa_offset 16
860    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
861    CFI_INSTRUCTION def_cfa_offset 24
862    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
863    CFI_INSTRUCTION def_cfa_offset 32
864    frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
865    CFI_INSTRUCTION def_cfa_offset 40
866    frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
867    CFI_INSTRUCTION def_cfa_offset 48
868    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
869    CFI_INSTRUCTION def_cfa_offset 56
870    CFI_INSTRUCTION offset $rbx, -56
871    CFI_INSTRUCTION offset $r12, -48
872    CFI_INSTRUCTION offset $r13, -40
873    CFI_INSTRUCTION offset $r14, -32
874    CFI_INSTRUCTION offset $r15, -24
875    CFI_INSTRUCTION offset $rbp, -16
876    MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0)
877    MOV64mr $rsp, 1, $noreg, -16, $noreg, killed renamable $r10 :: (store (s64) into %stack.1)
878    INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !520, debug-location !518
879    renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)
880    renamable $r10 = MOV64rm $rsp, 1, $noreg, -16, $noreg :: (load (s64) from %stack.1)
881    ; Clobber stack location to force variable location to move to $rdi.
882    $rax = MOV64ri 0
883    MOV64mr $rsp, 1, _, -8, _, renamable $rax :: (store (s64) into %stack.0)
884    MOV64mr $rsp, 1, _, -16, _, killed renamable $rax :: (store (s64) into %stack.1)
885    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
886    CFI_INSTRUCTION def_cfa_offset 48
887    $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
888    CFI_INSTRUCTION def_cfa_offset 40
889    $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
890    CFI_INSTRUCTION def_cfa_offset 32
891    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
892    CFI_INSTRUCTION def_cfa_offset 24
893    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp
894    CFI_INSTRUCTION def_cfa_offset 16
895    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
896    CFI_INSTRUCTION def_cfa_offset 8
897
898  bb.2.if.end:
899    liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp
900
901    renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !523 :: (load (s32) from %ir.add.ptr, !tbaa !24)
902    RET64 $eax, debug-location !528
903
904
905
906...
907