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).
5
6target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-pc-linux-gnu"
8
9declare zeroext i1 @return_i1()
10
11define i1 @test(i32 addrspace(1)* %ptr) gc "statepoint-example" {
12; CHECK-LABEL: test
13; Do we see one spill for the local value and the store to the
14; alloca?
15; CHECK: subq	$24, %rsp
16; CHECK: movq	$0, 8(%rsp)
17; CHECK: movq	%rdi, (%rsp)
18; CHECK: callq return_i1
19; CHECK: addq	$24, %rsp
20; CHECK: retq
21entry:
22  %metadata1 = alloca i32 addrspace(1)*, i32 2, align 8
23  store i32 addrspace(1)* null, i32 addrspace(1)** %metadata1
24  %safepoint_token = tail call i32 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 2, i32 addrspace(1)* %ptr, i32 addrspace(1)* null, i32 addrspace(1)* %ptr, i32 addrspace(1)* null)
25  %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token)
26  %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 6, i32 6)
27  %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 7, i32 7)
28;
29  ret i1 %call1
30}
31
32declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...)
33declare i1 @llvm.experimental.gc.result.i1(i32)
34declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) #3
35
36
37; CHECK-LABEL: .section .llvm_stackmaps
38; CHECK-NEXT:  __LLVM_StackMaps:
39; Header
40; CHECK-NEXT:   .byte 1
41; CHECK-NEXT:   .byte 0
42; CHECK-NEXT:   .short 0
43; Num Functions
44; CHECK-NEXT:   .long 1
45; Num LargeConstants
46; CHECK-NEXT:   .long 0
47; Num Callsites
48; CHECK-NEXT:   .long 1
49
50; Functions and stack size
51; CHECK-NEXT:   .quad test
52; CHECK-NEXT:   .quad 24
53
54; Large Constants
55; Statepoint ID only
56; CHECK: .quad	2882400000
57
58; Callsites
59; Constant arguments
60; CHECK: .long	.Ltmp1-test
61; CHECK: .short	0
62; CHECK: .short	8
63; SmallConstant (0)
64; CHECK: .byte	4
65; CHECK: .byte	8
66; CHECK: .short	0
67; CHECK: .long	0
68; SmallConstant (2)
69; CHECK: .byte	4
70; CHECK: .byte	8
71; CHECK: .short	0
72; CHECK: .long	2
73; Direct Spill Slot [RSP+0]
74; CHECK: .byte	2
75; CHECK: .byte	8
76; CHECK: .short	7
77; CHECK: .long	0
78; SmallConstant  (0)
79; CHECK: .byte	4
80; CHECK: .byte	8
81; CHECK: .short	0
82; CHECK: .long	0
83; SmallConstant  (0)
84; CHECK: .byte	4
85; CHECK: .byte	8
86; CHECK: .short	0
87; CHECK: .long	0
88; SmallConstant  (0)
89; CHECK: .byte	4
90; CHECK: .byte	8
91; CHECK: .short	0
92; CHECK: .long	0
93; Direct Spill Slot [RSP+0]
94; CHECK: .byte	2
95; CHECK: .byte	8
96; CHECK: .short	7
97; CHECK: .long	0
98; Direct Spill Slot [RSP+0]
99; CHECK: .byte	2
100; CHECK: .byte	8
101; CHECK: .short	7
102; CHECK: .long	0
103
104; No Padding or LiveOuts
105; CHECK: .short	0
106; CHECK: .short	0
107; CHECK: .align	8
108
109
110