Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/CodeGen/AMDGPU/sibling-call.ll
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | |||||
define fastcc i32 @sibling_call_i32_fastcc_i32_byval_i32(i32 %a, [32 x i32] %large) #1 { | define fastcc i32 @sibling_call_i32_fastcc_i32_byval_i32(i32 %a, [32 x i32] %large) #1 { | ||||
entry: | entry: | ||||
%ret = tail call fastcc i32 @i32_fastcc_i32_byval_i32(i32 %a, i32 addrspace(5)* byval(i32) inttoptr (i32 16 to i32 addrspace(5)*)) | %ret = tail call fastcc i32 @i32_fastcc_i32_byval_i32(i32 %a, i32 addrspace(5)* byval(i32) inttoptr (i32 16 to i32 addrspace(5)*)) | ||||
ret i32 %ret | ret i32 %ret | ||||
} | } | ||||
; GCN-LABEL: {{^}}i32_fastcc_i32_i32_a32i32: | ; GCN-LABEL: {{^}}i32_fastcc_i32_i32_a32i32: | ||||
; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||||
; GCN-DAG: buffer_load_dword [[LOAD_0:v[0-9]+]], off, s[0:3], s32{{$}} | ; GCN-DAG: buffer_load_dword [[LOAD_0:v[0-9]+]], off, s[0:3], s32 offset:8 | ||||
; GCN-DAG: buffer_load_dword [[LOAD_1:v[0-9]+]], off, s[0:3], s32 offset:4 | ; GCN-DAG: buffer_load_dword [[LOAD_1:v[0-9]+]], off, s[0:3], s32 offset:4 | ||||
; CIVI-NEXT: v_add_{{i|u}}32_e32 v0, vcc, v0, v1 | ; CIVI-NEXT: v_add_{{i|u}}32_e32 v0, vcc, v0, v1 | ||||
; CIVI: v_add_{{i|u}}32_e32 v0, vcc, v0, [[LOAD_0]] | |||||
; CIVI: v_add_{{i|u}}32_e32 v0, vcc, v0, [[LOAD_1]] | ; CIVI: v_add_{{i|u}}32_e32 v0, vcc, v0, [[LOAD_1]] | ||||
; CIVI: v_add_{{i|u}}32_e32 v0, vcc, v0, [[LOAD_0]] | |||||
; GFX9-NEXT: v_add_u32_e32 v0, v0, v1 | ; GFX9-NEXT: v_add_u32_e32 v0, v0, v1 | ||||
; GFX9: v_add3_u32 v0, v0, v3, v2 | ; GFX9: v_add3_u32 v0, v0, v3, v2 | ||||
; GCN-NEXT: s_setpc_b64 | ; GCN-NEXT: s_setpc_b64 | ||||
define fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %arg0, i32 %arg1, [32 x i32] %large) #1 { | define fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %arg0, i32 %arg1, [32 x i32] %large) #1 { | ||||
%val_firststack = extractvalue [32 x i32] %large, 30 | %val_firststack = extractvalue [32 x i32] %large, 30 | ||||
%val_laststack = extractvalue [32 x i32] %large, 31 | %val_laststack = extractvalue [32 x i32] %large, 31 | ||||
%add0 = add i32 %arg0, %arg1 | %add0 = add i32 %arg0, %arg1 | ||||
%add1 = add i32 %add0, %val_firststack | %add1 = add i32 %add0, %val_firststack | ||||
%add2 = add i32 %add1, %val_laststack | %add2 = add i32 %add1, %val_laststack | ||||
ret i32 %add2 | ret i32 %add2 | ||||
} | } | ||||
; FIXME: Why load and store same location for stack args? | ; FIXME: Why load and store same location for stack args? | ||||
; GCN-LABEL: {{^}}sibling_call_i32_fastcc_i32_i32_a32i32: | ; GCN-LABEL: {{^}}sibling_call_i32_fastcc_i32_i32_a32i32: | ||||
; GCN-DAG: buffer_load_dword [[LOAD_0:v[0-9]+]], off, s[0:3], s32{{$}} | ; GCN-DAG: buffer_load_dword [[LOAD_0:v[0-9]+]], off, s[0:3], s32{{$}} | ||||
; GCN-DAG: buffer_load_dword [[LOAD_1:v[0-9]+]], off, s[0:3], s32 offset:4 | ; GCN-DAG: buffer_load_dword [[LOAD_1:v[0-9]+]], off, s[0:3], s32 offset:4 | ||||
; GCN-NOT: s32 | |||||
; GCN-DAG: buffer_store_dword [[LOAD_0]], off, s[0:3], s32{{$}} | ; GCN-DAG: buffer_store_dword [[LOAD_0]], off, s[0:3], s32{{$}} | ||||
; GCN-DAG: buffer_store_dword [[LOAD_1]], off, s[0:3], s32 offset:4 | ; GCN-DAG: buffer_store_dword [[LOAD_1]], off, s[0:3], s32 offset:4 | ||||
; GCN-NOT: s32 | |||||
; GCN: s_setpc_b64 | ; GCN: s_setpc_b64 | ||||
define fastcc i32 @sibling_call_i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) #1 { | define fastcc i32 @sibling_call_i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) #1 { | ||||
entry: | entry: | ||||
%ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) | %ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) | ||||
ret i32 %ret | ret i32 %ret | ||||
} | } | ||||
; GCN-LABEL: {{^}}sibling_call_i32_fastcc_i32_i32_a32i32_stack_object: | ; GCN-LABEL: {{^}}sibling_call_i32_fastcc_i32_i32_a32i32_stack_object: | ||||
; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9 | ; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9 | ||||
; GCN: buffer_store_dword [[NINE]], off, s[0:3], s32 offset:28 | ; GCN: buffer_store_dword [[NINE]], off, s[0:3], s32 offset:32 | ||||
; GCN: s_setpc_b64 | ; GCN: s_setpc_b64 | ||||
define fastcc i32 @sibling_call_i32_fastcc_i32_i32_a32i32_stack_object(i32 %a, i32 %b, [32 x i32] %c) #1 { | define fastcc i32 @sibling_call_i32_fastcc_i32_i32_a32i32_stack_object(i32 %a, i32 %b, [32 x i32] %c) #1 { | ||||
entry: | entry: | ||||
%alloca = alloca [16 x i32], align 4, addrspace(5) | %alloca = alloca [16 x i32], align 4, addrspace(5) | ||||
%gep = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 5 | %gep = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 5 | ||||
store volatile i32 9, i32 addrspace(5)* %gep | store volatile i32 9, i32 addrspace(5)* %gep | ||||
%ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) | %ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) | ||||
ret i32 %ret | ret i32 %ret | ||||
Show All 10 Lines | |||||
entry: | entry: | ||||
%ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] zeroinitializer) | %ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] zeroinitializer) | ||||
ret i32 %ret | ret i32 %ret | ||||
} | } | ||||
; Have another non-tail in the function | ; Have another non-tail in the function | ||||
; GCN-LABEL: {{^}}sibling_call_i32_fastcc_i32_i32_other_call: | ; GCN-LABEL: {{^}}sibling_call_i32_fastcc_i32_i32_other_call: | ||||
; GCN: s_or_saveexec_b64 s{{\[[0-9]+:[0-9]+\]}}, -1 | ; GCN: s_or_saveexec_b64 s{{\[[0-9]+:[0-9]+\]}}, -1 | ||||
; GCN-NEXT: buffer_store_dword v42, off, s[0:3], s32 offset:8 ; 4-byte Folded Spill | ; GCN-NEXT: buffer_store_dword v43, off, s[0:3], s32 offset:12 ; 4-byte Folded Spill | ||||
; GCN-NEXT: s_mov_b64 exec | ; GCN-NEXT: s_mov_b64 exec | ||||
; GCN: s_mov_b32 s33, s32 | ; GCN: s_mov_b32 s33, s32 | ||||
; GCN-DAG: s_add_u32 s32, s32, 0x400 | ; GCN-DAG: s_add_u32 s32, s32, 0x800 | ||||
; GCN-DAG: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill | ; GCN-DAG: buffer_store_dword v40, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill | ||||
; GCN-DAG: buffer_store_dword v41, off, s[0:3], s33 ; 4-byte Folded Spill | ; GCN-DAG: buffer_store_dword v41, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill | ||||
; GCN-DAG: v_writelane_b32 v42, s34, 0 | ; GCN-DAG: v_writelane_b32 v43, s46, 12 | ||||
; GCN-DAG: v_writelane_b32 v42, s35, 1 | |||||
; GCN-DAG: s_getpc_b64 s[4:5] | ; GCN-DAG: s_getpc_b64 s[4:5] | ||||
; GCN-DAG: s_add_u32 s4, s4, i32_fastcc_i32_i32@gotpcrel32@lo+4 | ; GCN-DAG: s_add_u32 s4, s4, i32_fastcc_i32_i32@gotpcrel32@lo+4 | ||||
; GCN-DAG: s_addc_u32 s5, s5, i32_fastcc_i32_i32@gotpcrel32@hi+12 | ; GCN-DAG: s_addc_u32 s5, s5, i32_fastcc_i32_i32@gotpcrel32@hi+12 | ||||
; GCN: s_swappc_b64 | ; GCN: s_swappc_b64 | ||||
; GCN-DAG: buffer_load_dword v41, off, s[0:3], s33 ; 4-byte Folded Reload | ; GCN-DAG: buffer_load_dword v41, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload | ||||
; GCN-DAG: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload | ; GCN-DAG: buffer_load_dword v40, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload | ||||
; GCN: s_getpc_b64 s[4:5] | ; GCN: s_getpc_b64 s[16:17] | ||||
; GCN-NEXT: s_add_u32 s4, s4, sibling_call_i32_fastcc_i32_i32@rel32@lo+4 | ; GCN-NEXT: s_add_u32 s16, s16, sibling_call_i32_fastcc_i32_i32@rel32@lo+4 | ||||
; GCN-NEXT: s_addc_u32 s5, s5, sibling_call_i32_fastcc_i32_i32@rel32@hi+12 | ; GCN-NEXT: s_addc_u32 s17, s17, sibling_call_i32_fastcc_i32_i32@rel32@hi+12 | ||||
; GCN-DAG: v_readlane_b32 s34, v42, 0 | ; GCN-DAG: v_readlane_b32 s35, v43, 1 | ||||
; GCN-DAG: v_readlane_b32 s35, v42, 1 | ; GCN-DAG: v_readlane_b32 s34, v43, 0 | ||||
; GCN: s_sub_u32 s32, s32, 0x400 | ; GCN: s_sub_u32 s32, s32, 0x800 | ||||
; GCN-NEXT: v_readlane_b32 s33, | ; GCN-NEXT: v_readlane_b32 s33, | ||||
; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1 | ; GCN-NEXT: s_or_saveexec_b64 s[18:19], -1 | ||||
; GCN-NEXT: buffer_load_dword v42, off, s[0:3], s32 offset:8 ; 4-byte Folded Reload | ; GCN-NEXT: buffer_load_dword v43, off, s[0:3], s32 offset:12 ; 4-byte Folded Reload | ||||
; GCN-NEXT: s_mov_b64 exec, s[6:7] | ; GCN-NEXT: s_mov_b64 exec, s[18:19] | ||||
; GCN-NEXT: s_setpc_b64 s[4:5] | ; GCN-NEXT: s_setpc_b64 s[16:17] | ||||
define fastcc i32 @sibling_call_i32_fastcc_i32_i32_other_call(i32 %a, i32 %b, i32 %c) #1 { | define fastcc i32 @sibling_call_i32_fastcc_i32_i32_other_call(i32 %a, i32 %b, i32 %c) #1 { | ||||
entry: | entry: | ||||
%other.call = tail call fastcc i32 @i32_fastcc_i32_i32(i32 %a, i32 %b) | %other.call = tail call fastcc i32 @i32_fastcc_i32_i32(i32 %a, i32 %b) | ||||
%ret = tail call fastcc i32 @sibling_call_i32_fastcc_i32_i32(i32 %a, i32 %b, i32 %other.call) | %ret = tail call fastcc i32 @sibling_call_i32_fastcc_i32_i32(i32 %a, i32 %b, i32 %other.call) | ||||
ret i32 %ret | ret i32 %ret | ||||
} | } | ||||
; Have stack object in caller and stack passed arguments. SP should be | ; Have stack object in caller and stack passed arguments. SP should be | ||||
; in same place at function exit. | ; in same place at function exit. | ||||
; GCN-LABEL: {{^}}sibling_call_stack_objecti32_fastcc_i32_i32_a32i32: | ; GCN-LABEL: {{^}}sibling_call_stack_objecti32_fastcc_i32_i32_a32i32: | ||||
; GCN-NOT: s33 | ; GCN-NOT: s33 | ||||
; GCN: buffer_load_dword v{{[0-9]+}}, off, s[0:3], s32 offset: | ; GCN: buffer_load_dword v{{[0-9]+}}, off, s[0:3], s32 offset: | ||||
; GCN-NOT: s33 | ; GCN-NOT: s33 | ||||
; GCN: buffer_store_dword v{{[0-9]+}}, off, s[0:3], s32 offset: | ; GCN: buffer_store_dword v{{[0-9]+}}, off, s[0:3], s32 offset: | ||||
; GCN: s_setpc_b64 s[4:5] | ; GCN: s_setpc_b64 s[16:17] | ||||
define fastcc i32 @sibling_call_stack_objecti32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) #1 { | define fastcc i32 @sibling_call_stack_objecti32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) #1 { | ||||
entry: | entry: | ||||
%alloca = alloca [16 x i32], align 4, addrspace(5) | %alloca = alloca [16 x i32], align 4, addrspace(5) | ||||
%gep = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 5 | %gep = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 5 | ||||
store volatile i32 9, i32 addrspace(5)* %gep | store volatile i32 9, i32 addrspace(5)* %gep | ||||
%ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) | %ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] %c) | ||||
ret i32 %ret | ret i32 %ret | ||||
} | } | ||||
; GCN-LABEL: {{^}}sibling_call_stack_objecti32_fastcc_i32_i32_a32i32_larger_arg_area: | ; GCN-LABEL: {{^}}sibling_call_stack_objecti32_fastcc_i32_i32_a32i32_larger_arg_area: | ||||
; GCN-NOT: s33 | ; GCN-NOT: s33 | ||||
; GCN: buffer_store_dword v{{[0-9]+}}, off, s[0:3], s32 offset:44 | ; GCN: buffer_store_dword v{{[0-9]+}}, off, s[0:3], s32 offset:48 | ||||
; GCN-NOT: s33 | ; GCN-NOT: s33 | ||||
; GCN: s_setpc_b64 s[4:5] | ; GCN: s_setpc_b64 s[16:17] | ||||
define fastcc i32 @sibling_call_stack_objecti32_fastcc_i32_i32_a32i32_larger_arg_area(i32 %a, i32 %b, [36 x i32] %c) #1 { | define fastcc i32 @sibling_call_stack_objecti32_fastcc_i32_i32_a32i32_larger_arg_area(i32 %a, i32 %b, [36 x i32] %c) #1 { | ||||
entry: | entry: | ||||
%alloca = alloca [16 x i32], align 4, addrspace(5) | %alloca = alloca [16 x i32], align 4, addrspace(5) | ||||
%gep = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 5 | %gep = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 5 | ||||
store volatile i32 9, i32 addrspace(5)* %gep | store volatile i32 9, i32 addrspace(5)* %gep | ||||
%ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] zeroinitializer) | %ret = tail call fastcc i32 @i32_fastcc_i32_i32_a32i32(i32 %a, i32 %b, [32 x i32] zeroinitializer) | ||||
ret i32 %ret | ret i32 %ret | ||||
} | } | ||||
attributes #0 = { nounwind } | attributes #0 = { nounwind } | ||||
attributes #1 = { nounwind noinline } | attributes #1 = { nounwind noinline } |