[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / llvm / test / CodeGen / AMDGPU / recursion.ll
blob14c97508da6a489ee1e1d9d1d089ef539f280aee
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() {
6   call void @recursive()
7   store volatile i32 0, i32 addrspace(1)* undef
8   ret void
11 ; CHECK-LABEL: {{^}}tail_recursive:
12 ; CHECK: ScratchSize: 0
13 define void @tail_recursive() {
14   tail call void @tail_recursive()
15   ret void
18 define void @calls_tail_recursive() norecurse {
19   tail call void @tail_recursive()
20   ret void
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()
28   ret void
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()
36   ret void
39 ; Make sure we do not report a huge stack size for tail recursive
40 ; functions
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()
45   ret void
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
50 ; in the kernel.
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()
56   ret void
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()
63   ret void