1 ; RUN: llc -mtriple=riscv64 < %s | FileCheck %s
3 ; CHECK-LABEL: .section .llvm_stackmaps
4 ; CHECK-NEXT: __LLVM_StackMaps:
10 ; CHECK-NEXT: .word 12
14 ; CHECK-NEXT: .word 16
16 ; Functions and stack size
17 ; CHECK-NEXT: .quad constantargs
20 ; CHECK-NEXT: .quad osrinline
21 ; CHECK-NEXT: .quad 32
23 ; CHECK-NEXT: .quad osrcold
26 ; CHECK-NEXT: .quad propertyRead
27 ; CHECK-NEXT: .quad 16
29 ; CHECK-NEXT: .quad propertyWrite
32 ; CHECK-NEXT: .quad jsVoidCall
35 ; CHECK-NEXT: .quad jsIntCall
38 ; CHECK-NEXT: .quad liveConstant
41 ; CHECK-NEXT: .quad spilledValue
42 ; CHECK-NEXT: .quad 144
44 ; CHECK-NEXT: .quad directFrameIdx
45 ; CHECK-NEXT: .quad 48
47 ; CHECK-NEXT: .quad longid
50 ; CHECK-NEXT: .quad needsStackRealignment
51 ; CHECK-NEXT: .quad -1
55 ; CHECK-NEXT: .quad 4294967295
56 ; CHECK-NEXT: .quad 4294967296
61 ; CHECK-NEXT: .word .L{{.*}}-constantargs
70 ; CHECK-NEXT: .word 65535
77 ; CHECK-NEXT: .word 65536
85 ; LargeConstant at index 0
93 define void @constantargs() {
95 %0 = inttoptr i64 244837814094590 to ptr
96 tail call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 1, i32 28, ptr %0, i32 0, i64 65535, i64 65536, i64 4294967295, i64 4294967296)
102 ; CHECK: .word .L{{.*}}-osrinline
103 ; CHECK-NEXT: .half 0
104 ; CHECK-NEXT: .half 2
105 ; CHECK-NEXT: .byte 1
106 ; CHECK-NEXT: .byte 0
107 ; CHECK-NEXT: .half 8
108 ; CHECK-NEXT: .half {{[0-9]+}}
109 ; CHECK-NEXT: .half 0
110 ; CHECK-NEXT: .word 0
111 ; CHECK-NEXT: .byte 1
112 ; CHECK-NEXT: .byte 0
113 ; CHECK-NEXT: .half 8
114 ; CHECK-NEXT: .half {{[0-9]+}}
115 ; CHECK-NEXT: .half 0
116 ; CHECK-NEXT: .word 0
117 define void @osrinline(i64 %a, i64 %b) {
119 ; Runtime void->void call.
120 call void inttoptr (i64 244837814094590 to ptr)()
121 ; Followed by inline OSR patchpoint with 12-byte shadow and 2 live vars.
122 call void (i64, i32, ...) @llvm.experimental.stackmap(i64 3, i32 12, i64 %a, i64 %b)
128 ; 2 live variables in register.
130 ; CHECK: .word .L{{.*}}-osrcold
131 ; CHECK-NEXT: .half 0
132 ; CHECK-NEXT: .half 2
133 ; CHECK-NEXT: .byte 1
134 ; CHECK-NEXT: .byte 0
135 ; CHECK-NEXT: .half 8
136 ; CHECK-NEXT: .half {{[0-9]+}}
137 ; CHECK-NEXT: .half 0
138 ; CHECK-NEXT: .word 0
139 ; CHECK-NEXT: .byte 1
140 ; CHECK-NEXT: .byte 0
141 ; CHECK-NEXT: .half 8
142 ; CHECK-NEXT: .half {{[0-9]+}}
143 ; CHECK-NEXT: .half 0
144 ; CHECK-NEXT: .word 0
145 define void @osrcold(i64 %a, i64 %b) {
147 %test = icmp slt i64 %a, %b
148 br i1 %test, label %ret, label %cold
150 ; OSR patchpoint with 28-byte nop-slide and 2 live vars.
151 %thunk = inttoptr i64 244837814094590 to ptr
152 call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 4, i32 28, ptr %thunk, i32 0, i64 %a, i64 %b)
159 ; CHECK-LABEL: .word .L{{.*}}-propertyRead
160 ; CHECK-NEXT: .half 0
161 ; CHECK-NEXT: .half 2
162 ; CHECK-NEXT: .byte 1
163 ; CHECK-NEXT: .byte 0
164 ; CHECK-NEXT: .half 8
165 ; CHECK-NEXT: .half {{[0-9]+}}
166 ; CHECK-NEXT: .half 0
167 ; CHECK-NEXT: .word 0
168 ; CHECK-NEXT: .byte 1
169 ; CHECK-NEXT: .byte 0
170 ; CHECK-NEXT: .half 8
171 ; CHECK-NEXT: .half {{[0-9]+}}
172 ; CHECK-NEXT: .half 0
173 ; CHECK-NEXT: .word 0
174 define i64 @propertyRead(ptr %obj) {
176 %resolveRead = inttoptr i64 244837814094590 to ptr
177 %result = call anyregcc i64 (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.i64(i64 5, i32 28, ptr %resolveRead, i32 1, ptr %obj)
178 %add = add i64 %result, 3
183 ; CHECK: .word .L{{.*}}-propertyWrite
184 ; CHECK-NEXT: .half 0
185 ; CHECK-NEXT: .half 2
186 ; CHECK-NEXT: .byte 1
187 ; CHECK-NEXT: .byte 0
188 ; CHECK-NEXT: .half 8
189 ; CHECK-NEXT: .half {{[0-9]+}}
190 ; CHECK-NEXT: .half 0
191 ; CHECK-NEXT: .word 0
192 ; CHECK-NEXT: .byte 1
193 ; CHECK-NEXT: .byte 0
194 ; CHECK-NEXT: .half 8
195 ; CHECK-NEXT: .half {{[0-9]+}}
196 ; CHECK-NEXT: .half 0
197 ; CHECK-NEXT: .word 0
198 define void @propertyWrite(i64 %dummy1, ptr %obj, i64 %dummy2, i64 %a) {
200 %resolveWrite = inttoptr i64 244837814094590 to ptr
201 call anyregcc void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 6, i32 28, ptr %resolveWrite, i32 2, ptr %obj, i64 %a)
207 ; 2 live variables in registers.
209 ; CHECK: .word .L{{.*}}-jsVoidCall
210 ; CHECK-NEXT: .half 0
211 ; CHECK-NEXT: .half 2
212 ; CHECK-NEXT: .byte 1
213 ; CHECK-NEXT: .byte 0
214 ; CHECK-NEXT: .half 8
215 ; CHECK-NEXT: .half {{[0-9]+}}
216 ; CHECK-NEXT: .half 0
217 ; CHECK-NEXT: .word 0
218 ; CHECK-NEXT: .byte 1
219 ; CHECK-NEXT: .byte 0
220 ; CHECK-NEXT: .half 8
221 ; CHECK-NEXT: .half {{[0-9]+}}
222 ; CHECK-NEXT: .half 0
223 ; CHECK-NEXT: .word 0
224 define void @jsVoidCall(i64 %dummy1, ptr %obj, i64 %arg, i64 %l1, i64 %l2) {
226 %resolveCall = inttoptr i64 244837814094590 to ptr
227 call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 7, i32 28, ptr %resolveCall, i32 2, ptr %obj, i64 %arg, i64 %l1, i64 %l2)
233 ; 2 live variables in registers.
235 ; CHECK: .word .L{{.*}}-jsIntCall
236 ; CHECK-NEXT: .half 0
237 ; CHECK-NEXT: .half 2
238 ; CHECK-NEXT: .byte 1
239 ; CHECK-NEXT: .byte 0
240 ; CHECK-NEXT: .half 8
241 ; CHECK-NEXT: .half {{[0-9]+}}
242 ; CHECK-NEXT: .half 0
243 ; CHECK-NEXT: .word 0
244 ; CHECK-NEXT: .byte 1
245 ; CHECK-NEXT: .byte 0
246 ; CHECK-NEXT: .half 8
247 ; CHECK-NEXT: .half {{[0-9]+}}
248 ; CHECK-NEXT: .half 0
249 ; CHECK-NEXT: .word 0
250 define i64 @jsIntCall(i64 %dummy1, ptr %obj, i64 %arg, i64 %l1, i64 %l2) {
252 %resolveCall = inttoptr i64 244837814094590 to ptr
253 %result = call i64 (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.i64(i64 8, i32 28, ptr %resolveCall, i32 2, ptr %obj, i64 %arg, i64 %l1, i64 %l2)
254 %add = add i64 %result, 3
258 ; Map a constant value.
260 ; CHECK: .word .L{{.*}}-liveConstant
261 ; CHECK-NEXT: .half 0
263 ; CHECK-NEXT: .half 1
264 ; Loc 0: SmallConstant
265 ; CHECK-NEXT: .byte 4
266 ; CHECK-NEXT: .byte 0
267 ; CHECK-NEXT: .half 8
268 ; CHECK-NEXT: .half 0
269 ; CHECK-NEXT: .half 0
270 ; CHECK-NEXT: .word 33
272 define void @liveConstant() {
273 tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 15, i32 8, i32 33)
277 ; Spilled stack map values.
279 ; Verify 28 stack map entries.
281 ; CHECK-LABEL: .word .L{{.*}}-spilledValue
282 ; CHECK-NEXT: .half 0
283 ; CHECK-NEXT: .half 28
285 ; Check that at least one is a spilled entry from RBP.
286 ; Location: Indirect RBP + ...
288 ; CHECK-NEXT: .byte 0
289 ; CHECK-NEXT: .half 8
290 ; CHECK-NEXT: .half 2
291 ; CHECK-NEXT: .half 0
293 define void @spilledValue(i64 %arg0, i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27) {
295 call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 11, i32 28, ptr null, i32 5, i64 %arg0, i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %l0, i64 %l1, i64 %l2, i64 %l3, i64 %l4, i64 %l5, i64 %l6, i64 %l7, i64 %l8, i64 %l9, i64 %l10, i64 %l11, i64 %l12, i64 %l13, i64 %l14, i64 %l15, i64 %l16, i64 %l17, i64 %l18, i64 %l19, i64 %l20, i64 %l21, i64 %l22, i64 %l23, i64 %l24, i64 %l25, i64 %l26, i64 %l27)
299 ; Directly map an alloca's address.
302 ; CHECK-LABEL: .word .L{{.*}}-directFrameIdx
303 ; CHECK-NEXT: .half 0
305 ; CHECK-NEXT: .half 1
306 ; Loc 0: Direct RBP - ofs
307 ; CHECK-NEXT: .byte 2
308 ; CHECK-NEXT: .byte 0
309 ; CHECK-NEXT: .half 8
310 ; CHECK-NEXT: .half 2
311 ; CHECK-NEXT: .half 0
315 ; CHECK-LABEL: .word .L{{.*}}-directFrameIdx
316 ; CHECK-NEXT: .half 0
318 ; CHECK-NEXT: .half 2
319 ; Loc 0: Direct RBP - ofs
320 ; CHECK-NEXT: .byte 2
321 ; CHECK-NEXT: .byte 0
322 ; CHECK-NEXT: .half 8
323 ; CHECK-NEXT: .half 2
324 ; CHECK-NEXT: .half 0
326 ; Loc 1: Direct RBP - ofs
327 ; CHECK-NEXT: .byte 2
328 ; CHECK-NEXT: .byte 0
329 ; CHECK-NEXT: .half 8
330 ; CHECK-NEXT: .half 2
331 ; CHECK-NEXT: .half 0
333 define void @directFrameIdx() {
335 %metadata1 = alloca i64, i32 3, align 8
336 store i64 11, ptr %metadata1
337 store i64 12, ptr %metadata1
338 store i64 13, ptr %metadata1
339 call void (i64, i32, ...) @llvm.experimental.stackmap(i64 16, i32 0, ptr %metadata1)
340 %metadata2 = alloca i8, i32 4, align 8
341 %metadata3 = alloca i16, i32 4, align 8
342 call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 17, i32 4, ptr null, i32 0, ptr %metadata2, ptr %metadata3)
348 ; CHECK: .quad 4294967295
349 ; CHECK-LABEL: .word .L{{.*}}-longid
350 ; CHECK: .quad 4294967296
351 ; CHECK-LABEL: .word .L{{.*}}-longid
352 ; CHECK: .quad 9223372036854775807
353 ; CHECK-LABEL: .word .L{{.*}}-longid
355 ; CHECK-LABEL: .word .L{{.*}}-longid
356 define void @longid() {
358 tail call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 4294967295, i32 0, ptr null, i32 0)
359 tail call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 4294967296, i32 0, ptr null, i32 0)
360 tail call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 9223372036854775807, i32 0, ptr null, i32 0)
361 tail call void (i64, i32, ptr, i32, ...) @llvm.experimental.patchpoint.void(i64 -1, i32 0, ptr null, i32 0)
365 ; A stack frame which needs to be realigned at runtime (to meet alignment
366 ; criteria for values on the stack) does not have a fixed frame size.
367 ; CHECK-LABEL: .word .L{{.*}}-needsStackRealignment
368 ; CHECK-NEXT: .half 0
370 ; CHECK-NEXT: .half 0
371 define void @needsStackRealignment() {
372 %val = alloca i64, i32 3, align 128
373 tail call void (...) @escape_values(ptr %val)
374 ; Note: Adding any non-constant to the stackmap would fail because we
375 ; expected to be able to address off the frame pointer. In a realigned
376 ; frame, we must use the stack pointer instead. This is a separate bug.
377 tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 0)
380 declare void @escape_values(...)
382 declare void @llvm.experimental.stackmap(i64, i32, ...)
383 declare void @llvm.experimental.patchpoint.void(i64, i32, ptr, i32, ...)
384 declare i64 @llvm.experimental.patchpoint.i64(i64, i32, ptr, i32, ...)