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 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(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 7, i32 7)
30 %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 7, i32 8)
31 %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
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 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(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 7, i32 7)
58 %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 7, i32 8)
59 %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
65 declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...)
66 declare i1 @llvm.experimental.gc.result.i1(i32)
67 declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) #3
69 ; CHECK-LABEL: .section .llvm_stackmaps
70 ; CHECK-NEXT: __LLVM_StackMaps:
74 ; CHECK-NEXT: .short 0
82 ; Functions and stack size
83 ; CHECK-NEXT: .quad test
84 ; CHECK-NEXT: .quad 40
85 ; CHECK-NEXT: .quad test_derived_arg
86 ; CHECK-NEXT: .quad 40
94 ; CHECK: .quad 2882400000
98 ; CHECK: .long .Ltmp1-test
116 ; Direct Spill Slot [RSP+0]
136 ; Direct Spill Slot [RSP+16]
141 ; Direct Spill Slot [RSP+8]
146 ; Direct Spill Slot [RSP+16]
151 ; Direct Spill Slot [RSP+16]
157 ; No Padding or LiveOuts
168 ; CHECK: .quad 2882400000
172 ; CHECK: .long .Ltmp3-test_derived_arg
185 ; Direct Spill Slot [RSP+0]
205 ; Direct Spill Slot [RSP+16]
210 ; Direct Spill Slot [RSP+8]
215 ; Direct Spill Slot [RSP+16]
220 ; Direct Spill Slot [RSP+16]
226 ; No Padding or LiveOuts