1 ; RUN: llc < %s -mtriple="x86_64-pc-linux-gnu" | FileCheck %s
2 ; RUN: llc < %s -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
95 ; CHECK-NEXT: .quad test_derived_arg
96 ; CHECK-NEXT: .quad 40
97 ; CHECK-NEXT: .quad test_id
105 ; CHECK-NEXT: .quad 0
109 ; CHECK-NEXT: .long .Ltmp1-test
127 ; Indirect Spill Slot [RSP+0]
147 ; Indirect Spill Slot [RSP+16]
152 ; Indirect Spill Slot [RSP+8]
157 ; Indirect Spill Slot [RSP+16]
162 ; Indirect Spill Slot [RSP+16]
168 ; No Padding or LiveOuts
177 ; CHECK-NEXT: .quad 0
181 ; CHECK-NEXT: .long .Ltmp3-test_derived_arg
194 ; Indirect Spill Slot [RSP+0]
214 ; Indirect Spill Slot [RSP+16]
219 ; Indirect Spill Slot [RSP+8]
224 ; Indirect Spill Slot [RSP+16]
229 ; Indirect Spill Slot [RSP+16]
235 ; No Padding or LiveOuts
240 ; Records for the test_id function:
243 ; CHECK-NEXT: .quad 237
246 ; CHECK-NEXT: .long .Ltmp5-test_id
275 ; No padding or LiveOuts