1 ; RUN: sed 's/CODE_OBJECT_VERSION/400/g' %s | llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs | FileCheck %s
2 ; RUN: sed 's/CODE_OBJECT_VERSION/500/g' %s | llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs | FileCheck -check-prefixes=V5 %s
4 ; CHECK-LABEL: {{^}}recursive:
5 ; CHECK: ScratchSize: 16
6 define void @recursive() {
8 store volatile i32 0, ptr addrspace(1) undef
12 ; CHECK-LABEL: {{^}}tail_recursive:
13 ; CHECK: ScratchSize: 0
14 define void @tail_recursive() {
15 tail call void @tail_recursive()
19 define void @calls_tail_recursive() norecurse {
20 tail call void @tail_recursive()
24 ; CHECK-LABEL: {{^}}tail_recursive_with_stack:
25 define void @tail_recursive_with_stack() {
26 %alloca = alloca i32, addrspace(5)
27 store volatile i32 0, ptr addrspace(5) %alloca
28 tail call void @tail_recursive_with_stack()
32 ; For an arbitrary recursive call, report a large number for unknown stack
33 ; usage for code object v4 and older
34 ; CHECK-LABEL: {{^}}calls_recursive:
35 ; CHECK: .amdhsa_private_segment_fixed_size 16400{{$}}
37 ; V5-LABEL: {{^}}calls_recursive:
38 ; V5: .amdhsa_private_segment_fixed_size 0{{$}}
39 ; V5: .amdhsa_uses_dynamic_stack 1
40 define amdgpu_kernel void @calls_recursive() {
41 call void @recursive()
45 ; Make sure we do not report a huge stack size for tail recursive
47 ; CHECK-LABEL: {{^}}kernel_indirectly_calls_tail_recursive:
48 ; CHECK: .amdhsa_private_segment_fixed_size 0{{$}}
49 define amdgpu_kernel void @kernel_indirectly_calls_tail_recursive() {
50 call void @calls_tail_recursive()
54 ; TODO: Even though tail_recursive is only called as a tail call, we
55 ; end up treating it as generally recursive call from the regular call
58 ; CHECK-LABEL: {{^}}kernel_calls_tail_recursive:
59 ; CHECK: .amdhsa_private_segment_fixed_size 16384{{$}}
61 ; V5-LABEL: {{^}}kernel_calls_tail_recursive:
62 ; V5: .amdhsa_private_segment_fixed_size 0{{$}}
63 ; V5: .amdhsa_uses_dynamic_stack 1
64 define amdgpu_kernel void @kernel_calls_tail_recursive() {
65 call void @tail_recursive()
69 ; CHECK-LABEL: {{^}}kernel_calls_tail_recursive_with_stack:
70 ; CHECK: .amdhsa_private_segment_fixed_size 16384{{$}}
72 ; V5-LABEL: {{^}}kernel_calls_tail_recursive_with_stack:
73 ; V5: .amdhsa_private_segment_fixed_size 8{{$}}
74 ; V5: .amdhsa_uses_dynamic_stack 1
75 define amdgpu_kernel void @kernel_calls_tail_recursive_with_stack() {
76 call void @tail_recursive_with_stack()
80 !llvm.module.flags = !{!0}
81 !0 = !{i32 1, !"amdgpu_code_object_version", i32 CODE_OBJECT_VERSION}