1; RUN: llc -mtriple=amdgcn-amd-amdhsa -verify-machineinstrs -enable-ipra -amdgpu-sroa=0 < %s | FileCheck -check-prefix=GCN %s
2
3; Kernels are not called, so there is no call preserved mask.
4; GCN-LABEL: {{^}}kernel:
5; GCN: flat_store_dword
6define amdgpu_kernel void @kernel(i32 addrspace(1)* %out) #0 {
7entry:
8  store i32 0, i32 addrspace(1)* %out
9  ret void
10}
11
12; GCN-LABEL: {{^}}func:
13; GCN: ; NumVgprs: 8
14define void @func() #1 {
15  call void asm sideeffect "", "~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7}"() #0
16  ret void
17}
18
19; GCN-LABEL: {{^}}kernel_call:
20; GCN-NOT: buffer_store
21; GCN-NOT: buffer_load
22; GCN-NOT: readlane
23; GCN-NOT: writelane
24; GCN: flat_load_dword v8
25; GCN: s_swappc_b64
26; GCN-NOT: buffer_store
27; GCN-NOT: buffer_load
28; GCN-NOT: readlane
29; GCN-NOT: writelane
30; GCN: flat_store_dword v{{\[[0-9]+:[0-9]+\]}}, v8
31
32; GCN: ; NumSgprs: 37
33; GCN: ; NumVgprs: 9
34define amdgpu_kernel void @kernel_call() #0 {
35  %vgpr = load volatile i32, i32 addrspace(1)* undef
36  tail call void @func()
37  store volatile i32 %vgpr, i32 addrspace(1)* undef
38  ret void
39}
40
41; GCN-LABEL: {{^}}func_regular_call:
42; GCN-NOT: buffer_store
43; GCN-NOT: buffer_load
44; GCN-NOT: readlane
45; GCN-NOT: writelane
46; GCN: flat_load_dword v8
47; GCN: s_swappc_b64
48; GCN-NOT: buffer_store
49; GCN-NOT: buffer_load
50; GCN-NOT: readlane
51; GCN-NOT: writelane
52; GCN: flat_store_dword v{{\[[0-9]+:[0-9]+\]}}, v8
53
54; GCN: ; NumSgprs: 32
55; GCN: ; NumVgprs: 9
56define void @func_regular_call() #1 {
57  %vgpr = load volatile i32, i32 addrspace(1)* undef
58  tail call void @func()
59  store volatile i32 %vgpr, i32 addrspace(1)* undef
60  ret void
61}
62
63; GCN-LABEL: {{^}}func_tail_call:
64; GCN: s_waitcnt
65; GCN-NEXT: s_getpc_b64 s[6:7]
66; GCN-NEXT: s_add_u32 s6,
67; GCN-NEXT: s_addc_u32 s7,
68; GCN-NEXT: s_setpc_b64 s[6:7]
69
70; GCN: ; NumSgprs: 32
71; GCN: ; NumVgprs: 8
72define void @func_tail_call() #1 {
73  tail call void @func()
74  ret void
75}
76
77; GCN-LABEL: {{^}}func_call_tail_call:
78; GCN: flat_load_dword v8
79; GCN: s_swappc_b64
80; GCN: flat_store_dword v{{\[[0-9]+:[0-9]+\]}}, v8
81; GCN: s_setpc_b64
82
83; GCN: ; NumSgprs: 32
84; GCN: ; NumVgprs: 9
85define void @func_call_tail_call() #1 {
86  %vgpr = load volatile i32, i32 addrspace(1)* undef
87  tail call void @func()
88  store volatile i32 %vgpr, i32 addrspace(1)* undef
89  tail call void @func()
90  ret void
91}
92
93define void @void_func_void() noinline {
94  ret void
95}
96
97; Make sure we don't get save/restore of FP between calls.
98; GCN-LABEL: {{^}}test_funcx2:
99; GCN-NOT: s5
100; GCN-NOT: s32
101define void @test_funcx2() #0 {
102  call void @void_func_void()
103  call void @void_func_void()
104  ret void
105}
106
107attributes #0 = { nounwind }
108attributes #1 = { nounwind noinline }
109