1 ; RUN: llc < %s -verify-machineinstrs -stack-symbol-ordering=0 -mtriple="x86_64-pc-linux-gnu" | FileCheck %s
2 ; RUN: llc < %s -verify-machineinstrs -stack-symbol-ordering=0 -mtriple="x86_64-pc-unknown-elf" | FileCheck %s
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).
8 target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
10 declare zeroext i1 @return_i1()
12 define i1 @test(i32 addrspace(1)* %ptr_base, i32 %arg)
13 gc "statepoint-example" {
15 ; Do we see two spills for the local values and the store to the
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
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)
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
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
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)
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
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)
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
79 ; CHECK-LABEL: .section .llvm_stackmaps
80 ; CHECK-NEXT: __LLVM_StackMaps:
84 ; CHECK-NEXT: .short 0
92 ; Functions and stack size
93 ; CHECK-NEXT: .quad test
94 ; CHECK-NEXT: .quad 40
96 ; CHECK-NEXT: .quad test_derived_arg
97 ; CHECK-NEXT: .quad 40
99 ; CHECK-NEXT: .quad test_id
100 ; CHECK-NEXT: .quad 8
101 ; CHECK-NEXT: .quad 1
108 ; CHECK-NEXT: .quad 0
112 ; CHECK-NEXT: .long .Ltmp0-test
117 ; CHECK-NEXT: .byte 0
120 ; CHECK-NEXT: .short 0
124 ; CHECK-NEXT: .byte 0
127 ; CHECK-NEXT: .short 0
131 ; CHECK-NEXT: .byte 0
134 ; CHECK-NEXT: .short 0
136 ; Indirect Spill Slot [RSP+0]
138 ; CHECK-NEXT: .byte 0
141 ; CHECK-NEXT: .short 0
145 ; CHECK-NEXT: .byte 0
148 ; CHECK-NEXT: .short 0
152 ; CHECK-NEXT: .byte 0
155 ; CHECK-NEXT: .short 0
159 ; CHECK-NEXT: .byte 0
162 ; CHECK-NEXT: .short 0
164 ; Indirect Spill Slot [RSP+16]
166 ; CHECK-NEXT: .byte 0
169 ; CHECK-NEXT: .short 0
171 ; Indirect Spill Slot [RSP+8]
173 ; CHECK-NEXT: .byte 0
176 ; CHECK-NEXT: .short 0
178 ; Indirect Spill Slot [RSP+16]
180 ; CHECK-NEXT: .byte 0
183 ; CHECK-NEXT: .short 0
185 ; Indirect Spill Slot [RSP+16]
187 ; CHECK-NEXT: .byte 0
190 ; CHECK-NEXT: .short 0
193 ; No Padding or LiveOuts
202 ; CHECK-NEXT: .quad 0
206 ; CHECK-NEXT: .long .Ltmp1-test_derived_arg
211 ; CHECK-NEXT: .byte 0
214 ; CHECK-NEXT: .short 0
218 ; CHECK-NEXT: .byte 0
221 ; CHECK-NEXT: .short 0
223 ; Indirect Spill Slot [RSP+0]
225 ; CHECK-NEXT: .byte 0
228 ; CHECK-NEXT: .short 0
232 ; CHECK-NEXT: .byte 0
235 ; CHECK-NEXT: .short 0
239 ; CHECK-NEXT: .byte 0
242 ; CHECK-NEXT: .short 0
246 ; CHECK-NEXT: .byte 0
249 ; CHECK-NEXT: .short 0
251 ; Indirect Spill Slot [RSP+16]
253 ; CHECK-NEXT: .byte 0
256 ; CHECK-NEXT: .short 0
258 ; Indirect Spill Slot [RSP+8]
260 ; CHECK-NEXT: .byte 0
263 ; CHECK-NEXT: .short 0
265 ; Indirect Spill Slot [RSP+16]
267 ; CHECK-NEXT: .byte 0
270 ; CHECK-NEXT: .short 0
272 ; Indirect Spill Slot [RSP+16]
274 ; CHECK-NEXT: .byte 0
277 ; CHECK-NEXT: .short 0
280 ; No Padding or LiveOuts
285 ; Records for the test_id function:
288 ; CHECK-NEXT: .quad 237
291 ; CHECK-NEXT: .long .Ltmp2-test_id
302 ; CHECK-NEXT: .byte 0
305 ; CHECK-NEXT: .short 0
311 ; CHECK-NEXT: .byte 0
314 ; CHECK-NEXT: .short 0
320 ; CHECK-NEXT: .byte 0
323 ; CHECK-NEXT: .short 0
326 ; No padding or LiveOuts