]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/X86/statepoint-stackmap-format.ll
Vendor import of llvm trunk r291274:
[FreeBSD/FreeBSD.git] / test / CodeGen / X86 / statepoint-stackmap-format.ll
1 ; RUN: llc < %s -stack-symbol-ordering=0 -mtriple="x86_64-pc-linux-gnu" | FileCheck %s
2 ; RUN: llc < %s -stack-symbol-ordering=0 -mtriple="x86_64-pc-unknown-elf" | FileCheck %s
3
4 ; This test is a sanity check to ensure statepoints are generating StackMap
5 ; sections correctly.  This is not intended to be a rigorous test of the 
6 ; StackMap format (see the stackmap tests for that).
7
8 target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
9
10 declare zeroext i1 @return_i1()
11
12 define i1 @test(i32 addrspace(1)* %ptr_base, i32 %arg)
13   gc "statepoint-example" {
14 ; CHECK-LABEL: test:
15 ; Do we see two spills for the local values and the store to the
16 ; alloca?
17 ; CHECK: subq   $40, %rsp
18 ; CHECK: movq   $0,   24(%rsp)
19 ; CHECK: movq   %rdi, 16(%rsp)
20 ; CHECK: movq   %rax, 8(%rsp)
21 ; CHECK: callq return_i1
22 ; CHECK: addq   $40, %rsp
23 ; CHECK: retq
24 entry:
25   %metadata1 = alloca i32 addrspace(1)*, i32 2, align 8
26   store i32 addrspace(1)* null, i32 addrspace(1)** %metadata1
27   %ptr_derived = getelementptr i32, i32 addrspace(1)* %ptr_base, i32 %arg
28   %safepoint_token = tail call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 2, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* null, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* %ptr_derived, i32 addrspace(1)* null)
29   %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(token %safepoint_token)
30   %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 9, i32 9)
31   %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 9, i32 10)
32   %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 11, i32 11)
33
34   ret i1 %call1
35 }
36
37 ; This is similar to the previous test except that we have derived pointer as
38 ; argument to the function. Despite that this can not happen after the
39 ; RewriteSafepointForGC pass, lowering should be able to handle it anyway.
40 define i1 @test_derived_arg(i32 addrspace(1)* %ptr_base,
41                             i32 addrspace(1)* %ptr_derived)
42   gc "statepoint-example" {
43 ; CHECK-LABEL: test_derived_arg
44 ; Do we see two spills for the local values and the store to the
45 ; alloca?
46 ; CHECK: subq   $40, %rsp
47 ; CHECK: movq   $0,   24(%rsp)
48 ; CHECK: movq   %rdi, 16(%rsp)
49 ; CHECK: movq   %rsi, 8(%rsp)
50 ; CHECK: callq return_i1
51 ; CHECK: addq   $40, %rsp
52 ; CHECK: retq
53 entry:
54   %metadata1 = alloca i32 addrspace(1)*, i32 2, align 8
55   store i32 addrspace(1)* null, i32 addrspace(1)** %metadata1
56   %safepoint_token = tail call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 2, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* null, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* %ptr_derived, i32 addrspace(1)* null)
57   %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(token %safepoint_token)
58   %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 9, i32 9)
59   %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 9, i32 10)
60   %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 11, i32 11)
61
62   ret i1 %call1
63 }
64
65 ; Simple test case to check that we emit the ID field correctly
66 define i1 @test_id() gc "statepoint-example" {
67 ; CHECK-LABEL: test_id
68 entry:
69   %safepoint_token = tail call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 237, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0)
70   %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(token %safepoint_token)
71   ret i1 %call1
72 }
73
74
75 declare token @llvm.experimental.gc.statepoint.p0f_i1f(i64, i32, i1 ()*, i32, i32, ...)
76 declare i1 @llvm.experimental.gc.result.i1(token)
77 declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32) #3
78
79 ; CHECK-LABEL: .section .llvm_stackmaps
80 ; CHECK-NEXT:  __LLVM_StackMaps:
81 ; Header
82 ; CHECK-NEXT:   .byte 2
83 ; CHECK-NEXT:   .byte 0
84 ; CHECK-NEXT:   .short 0
85 ; Num Functions
86 ; CHECK-NEXT:   .long 3
87 ; Num LargeConstants
88 ; CHECK-NEXT:   .long 0
89 ; Num Callsites
90 ; CHECK-NEXT:   .long 3
91
92 ; Functions and stack size
93 ; CHECK-NEXT:   .quad test
94 ; CHECK-NEXT:   .quad 40
95 ; CHECK-NEXT:   .quad 1
96 ; CHECK-NEXT:   .quad test_derived_arg
97 ; CHECK-NEXT:   .quad 40
98 ; CHECK-NEXT:   .quad 1
99 ; CHECK-NEXT:   .quad test_id
100 ; CHECK-NEXT:   .quad 8
101 ; CHECK-NEXT:   .quad 1
102
103 ;
104 ; test
105 ;
106
107 ; Statepoint ID
108 ; CHECK-NEXT: .quad     0
109
110 ; Callsites
111 ; Constant arguments
112 ; CHECK-NEXT: .long     .Ltmp0-test
113 ; CHECK: .short 0
114 ; CHECK: .short 11
115 ; SmallConstant (0)
116 ; CHECK: .byte  4
117 ; CHECK: .byte  8
118 ; CHECK: .short 0
119 ; CHECK: .long  0
120 ; SmallConstant (0)
121 ; CHECK: .byte  4
122 ; CHECK: .byte  8
123 ; CHECK: .short 0
124 ; CHECK: .long  0
125 ; SmallConstant (2)
126 ; CHECK: .byte  4
127 ; CHECK: .byte  8
128 ; CHECK: .short 0
129 ; CHECK: .long  2
130 ; Indirect Spill Slot [RSP+0]
131 ; CHECK: .byte  3
132 ; CHECK: .byte  8
133 ; CHECK: .short 7
134 ; CHECK: .long  16
135 ; SmallConstant  (0)
136 ; CHECK: .byte  4
137 ; CHECK: .byte  8
138 ; CHECK: .short 0
139 ; CHECK: .long  0
140 ; SmallConstant  (0)
141 ; CHECK: .byte  4
142 ; CHECK: .byte  8
143 ; CHECK: .short 0
144 ; CHECK: .long  0
145 ; SmallConstant  (0)
146 ; CHECK: .byte  4
147 ; CHECK: .byte  8
148 ; CHECK: .short 0
149 ; CHECK: .long  0
150 ; Indirect Spill Slot [RSP+16]
151 ; CHECK: .byte  3
152 ; CHECK: .byte  8
153 ; CHECK: .short 7
154 ; CHECK: .long  16
155 ; Indirect Spill Slot [RSP+8]
156 ; CHECK: .byte  3
157 ; CHECK: .byte  8
158 ; CHECK: .short 7
159 ; CHECK: .long  8
160 ; Indirect Spill Slot [RSP+16]
161 ; CHECK: .byte  3
162 ; CHECK: .byte  8
163 ; CHECK: .short 7
164 ; CHECK: .long  16
165 ; Indirect Spill Slot [RSP+16]
166 ; CHECK: .byte  3
167 ; CHECK: .byte  8
168 ; CHECK: .short 7
169 ; CHECK: .long  16
170
171 ; No Padding or LiveOuts
172 ; CHECK: .short 0
173 ; CHECK: .short 0
174 ; CHECK: .p2align       3
175
176 ;
177 ; test_derived_arg
178
179 ; Statepoint ID
180 ; CHECK-NEXT: .quad     0
181
182 ; Callsites
183 ; Constant arguments
184 ; CHECK-NEXT: .long     .Ltmp1-test_derived_arg
185 ; CHECK: .short 0
186 ; CHECK: .short 11
187 ; SmallConstant (0)
188 ; CHECK: .byte  4
189 ; CHECK: .byte  8
190 ; CHECK: .short 0
191 ; CHECK: .long  0
192 ; SmallConstant (2)
193 ; CHECK: .byte  4
194 ; CHECK: .byte  8
195 ; CHECK: .short 0
196 ; CHECK: .long  2
197 ; Indirect Spill Slot [RSP+0]
198 ; CHECK: .byte  3
199 ; CHECK: .byte  8
200 ; CHECK: .short 7
201 ; CHECK: .long  16
202 ; SmallConstant  (0)
203 ; CHECK: .byte  4
204 ; CHECK: .byte  8
205 ; CHECK: .short 0
206 ; CHECK: .long  0
207 ; SmallConstant  (0)
208 ; CHECK: .byte  4
209 ; CHECK: .byte  8
210 ; CHECK: .short 0
211 ; CHECK: .long  0
212 ; SmallConstant  (0)
213 ; CHECK: .byte  4
214 ; CHECK: .byte  8
215 ; CHECK: .short 0
216 ; CHECK: .long  0
217 ; Indirect Spill Slot [RSP+16]
218 ; CHECK: .byte  3
219 ; CHECK: .byte  8
220 ; CHECK: .short 7
221 ; CHECK: .long  16
222 ; Indirect Spill Slot [RSP+8]
223 ; CHECK: .byte  3
224 ; CHECK: .byte  8
225 ; CHECK: .short 7
226 ; CHECK: .long  8
227 ; Indirect Spill Slot [RSP+16]
228 ; CHECK: .byte  3
229 ; CHECK: .byte  8
230 ; CHECK: .short 7
231 ; CHECK: .long  16
232 ; Indirect Spill Slot [RSP+16]
233 ; CHECK: .byte  3
234 ; CHECK: .byte  8
235 ; CHECK: .short 7
236 ; CHECK: .long  16
237
238 ; No Padding or LiveOuts
239 ; CHECK: .short 0
240 ; CHECK: .short 0
241 ; CHECK: .p2align       3
242
243 ; Records for the test_id function:
244
245 ; The Statepoint ID:
246 ; CHECK-NEXT: .quad     237
247
248 ; Instruction Offset
249 ; CHECK-NEXT: .long     .Ltmp2-test_id
250
251 ; Reserved:
252 ; CHECK: .short 0
253
254 ; NumLocations:
255 ; CHECK: .short 3
256
257 ; StkMapRecord[0]:
258 ; SmallConstant(0):
259 ; CHECK: .byte  4
260 ; CHECK: .byte  8
261 ; CHECK: .short 0
262 ; CHECK: .long  0
263
264 ; StkMapRecord[1]:
265 ; SmallConstant(0):
266 ; CHECK: .byte  4
267 ; CHECK: .byte  8
268 ; CHECK: .short 0
269 ; CHECK: .long  0
270
271 ; StkMapRecord[2]:
272 ; SmallConstant(0):
273 ; CHECK: .byte  4
274 ; CHECK: .byte  8
275 ; CHECK: .short 0
276 ; CHECK: .long  0
277
278 ; No padding or LiveOuts
279 ; CHECK: .short 0
280 ; CHECK: .short 0
281 ; CHECK: .p2align       3