1 ; RUN: llc < %s | FileCheck %s
2 ; This test is a sanity check to ensure statepoints are generating StackMap
3 ; sections correctly. This is not intended to be a rigorous test of the
4 ; StackMap format (see the stackmap tests for that).
6 target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-pc-linux-gnu"
9 declare zeroext i1 @return_i1()
11 define i1 @test(i32 addrspace(1)* %ptr_base, i32 %arg)
12 gc "statepoint-example" {
14 ; Do we see two spills for the local values and the store to the
16 ; CHECK: subq $40, %rsp
17 ; CHECK: movq $0, 24(%rsp)
18 ; CHECK: movq %rdi, 16(%rsp)
19 ; CHECK: movq %rax, 8(%rsp)
20 ; CHECK: callq return_i1
21 ; CHECK: addq $40, %rsp
24 %metadata1 = alloca i32 addrspace(1)*, i32 2, align 8
25 store i32 addrspace(1)* null, i32 addrspace(1)** %metadata1
26 %ptr_derived = getelementptr i32, i32 addrspace(1)* %ptr_base, i32 %arg
27 %safepoint_token = tail call i32 (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)
28 %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token)
29 %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
30 %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 10)
31 %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 11, i32 11)
36 ; This is similar to the previous test except that we have derived pointer as
37 ; argument to the function. Despite that this can not happen after the
38 ; RewriteSafepointForGC pass, lowering should be able to handle it anyway.
39 define i1 @test_derived_arg(i32 addrspace(1)* %ptr_base,
40 i32 addrspace(1)* %ptr_derived)
41 gc "statepoint-example" {
42 ; CHECK-LABEL: test_derived_arg
43 ; Do we see two spills for the local values and the store to the
45 ; CHECK: subq $40, %rsp
46 ; CHECK: movq $0, 24(%rsp)
47 ; CHECK: movq %rdi, 16(%rsp)
48 ; CHECK: movq %rsi, 8(%rsp)
49 ; CHECK: callq return_i1
50 ; CHECK: addq $40, %rsp
53 %metadata1 = alloca i32 addrspace(1)*, i32 2, align 8
54 store i32 addrspace(1)* null, i32 addrspace(1)** %metadata1
55 %safepoint_token = tail call i32 (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)
56 %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token)
57 %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
58 %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 10)
59 %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 11, i32 11)
64 ; Simple test case to check that we emit the ID field correctly
65 define i1 @test_id() gc "statepoint-example" {
66 ; CHECK-LABEL: test_id
68 %safepoint_token = tail call i32 (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)
69 %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token)
74 declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i64, i32, i1 ()*, i32, i32, ...)
75 declare i1 @llvm.experimental.gc.result.i1(i32)
76 declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) #3
78 ; CHECK-LABEL: .section .llvm_stackmaps
79 ; CHECK-NEXT: __LLVM_StackMaps:
83 ; CHECK-NEXT: .short 0
91 ; Functions and stack size
92 ; CHECK-NEXT: .quad test
93 ; CHECK-NEXT: .quad 40
94 ; CHECK-NEXT: .quad test_derived_arg
95 ; CHECK-NEXT: .quad 40
107 ; CHECK: .long .Ltmp1-test
125 ; Direct Spill Slot [RSP+0]
145 ; Direct Spill Slot [RSP+16]
150 ; Direct Spill Slot [RSP+8]
155 ; Direct Spill Slot [RSP+16]
160 ; Direct Spill Slot [RSP+16]
166 ; No Padding or LiveOuts
181 ; CHECK: .long .Ltmp3-test_derived_arg
194 ; Direct Spill Slot [RSP+0]
214 ; Direct Spill Slot [RSP+16]
219 ; Direct Spill Slot [RSP+8]
224 ; Direct Spill Slot [RSP+16]
229 ; Direct Spill Slot [RSP+16]
235 ; No Padding or LiveOuts
240 ; Records for the test_id function:
247 ; CHECK: .long .Ltmp5-test_id
276 ; No padding or LiveOuts