1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck -check-prefix=GCN %s
2
3; Make sure flat_scratch_init is set
4
5; GCN-LABEL: {{^}}stack_object_addrspacecast_in_kernel_no_calls:
6; GCN: .amdhsa_user_sgpr_flat_scratch_init 1
7define amdgpu_kernel void @stack_object_addrspacecast_in_kernel_no_calls() {
8  %alloca = alloca i32, addrspace(5)
9  %cast = addrspacecast i32 addrspace(5)* %alloca to i32*
10  store volatile i32 0, i32* %cast
11  ret void
12}
13
14; TODO: Could optimize out in this case
15; GCN-LABEL: {{^}}stack_object_in_kernel_no_calls:
16; GCN: .amdhsa_user_sgpr_flat_scratch_init 1
17define amdgpu_kernel void @stack_object_in_kernel_no_calls() {
18  %alloca = alloca i32, addrspace(5)
19  store volatile i32 0, i32 addrspace(5)* %alloca
20  ret void
21}
22
23; GCN-LABEL: {{^}}kernel_no_calls_no_stack:
24; GCN: .amdhsa_user_sgpr_flat_scratch_init 0
25define amdgpu_kernel void @kernel_no_calls_no_stack() {
26  ret void
27}
28