1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck %s
3 ; CHECK-LABEL: {{^}}recursive:
4 ; CHECK: ScratchSize: 16
5 define void @recursive() {
7 store volatile i32 0, i32 addrspace(1)* undef
11 ; CHECK-LABEL: {{^}}tail_recursive:
12 ; CHECK: ScratchSize: 0
13 define void @tail_recursive() {
14 tail call void @tail_recursive()
18 define void @calls_tail_recursive() norecurse {
19 tail call void @tail_recursive()
23 ; CHECK-LABEL: {{^}}tail_recursive_with_stack:
24 define void @tail_recursive_with_stack() {
25 %alloca = alloca i32, addrspace(5)
26 store volatile i32 0, i32 addrspace(5)* %alloca
27 tail call void @tail_recursive_with_stack()
31 ; For an arbitrary recursive call, report a large number for unknown stack usage.
32 ; CHECK-LABEL: {{^}}calls_recursive:
33 ; CHECK: .amdhsa_private_segment_fixed_size 16400{{$}}
34 define amdgpu_kernel void @calls_recursive() {
35 call void @recursive()
39 ; Make sure we do not report a huge stack size for tail recursive
41 ; CHECK-LABEL: {{^}}kernel_indirectly_calls_tail_recursive:
42 ; CHECK: .amdhsa_private_segment_fixed_size 0{{$}}
43 define amdgpu_kernel void @kernel_indirectly_calls_tail_recursive() {
44 call void @calls_tail_recursive()
48 ; TODO: Even though tail_recursive is only called as a tail call, we
49 ; end up treating it as generally recursive call from the regular call
52 ; CHECK-LABEL: {{^}}kernel_calls_tail_recursive:
53 ; CHECK: .amdhsa_private_segment_fixed_size 16384{{$}}
54 define amdgpu_kernel void @kernel_calls_tail_recursive() {
55 call void @tail_recursive()
59 ; CHECK-LABEL: {{^}}kernel_calls_tail_recursive_with_stack:
60 ; CHECK: .amdhsa_private_segment_fixed_size 16384{{$}}
61 define amdgpu_kernel void @kernel_calls_tail_recursive_with_stack() {
62 call void @tail_recursive_with_stack()