blob: 769c7bb3eee7ae5e3c147d8d850b21fd65fa18fe [file] [log] [blame]
Matt Arsenault9430b912016-05-18 16:10:11 +00001; RUN: not llc -march=amdgcn -verify-machineinstrs < %s 2>&1 | FileCheck %s
2; RUN: not llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s 2>&1 | FileCheck %s
3; RUN: not llc -march=r600 -mcpu=cypress < %s 2>&1 | FileCheck %s
Matt Arsenault16353872014-04-22 16:42:00 +00004
Oliver Stannard7e7d9832016-02-02 13:52:43 +00005; CHECK: in function test_call_external{{.*}}: unsupported call to function external_function
Matt Arsenault9430b912016-05-18 16:10:11 +00006; CHECK: in function test_call{{.*}}: unsupported call to function defined_function
7; CHECK: in function test_tail_call{{.*}}: unsupported call to function defined_function
Matt Arsenault0b386362016-12-15 20:50:12 +00008; CHECK: in function test_tail_call_bitcast_extern_variadic{{.*}}: unsupported call to function extern_variadic
Matt Arsenault16353872014-04-22 16:42:00 +00009
10
11declare i32 @external_function(i32) nounwind
12
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000013define amdgpu_kernel void @test_call_external(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
Matt Arsenaultdeaef8e2015-04-22 17:10:44 +000014 %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
15 %a = load i32, i32 addrspace(1)* %in
16 %b = load i32, i32 addrspace(1)* %b_ptr
17 %c = call i32 @external_function(i32 %b) nounwind
18 %result = add i32 %a, %c
19 store i32 %result, i32 addrspace(1)* %out
20 ret void
21}
22
Matt Arsenault16353872014-04-22 16:42:00 +000023define i32 @defined_function(i32 %x) nounwind noinline {
24 %y = add i32 %x, 8
25 ret i32 %y
26}
27
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000028define amdgpu_kernel void @test_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
David Blaikie79e6c742015-02-27 19:29:02 +000029 %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000030 %a = load i32, i32 addrspace(1)* %in
31 %b = load i32, i32 addrspace(1)* %b_ptr
Matt Arsenault16353872014-04-22 16:42:00 +000032 %c = call i32 @defined_function(i32 %b) nounwind
33 %result = add i32 %a, %c
34 store i32 %result, i32 addrspace(1)* %out
35 ret void
36}
Matt Arsenault9430b912016-05-18 16:10:11 +000037
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000038define amdgpu_kernel void @test_tail_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
Matt Arsenault9430b912016-05-18 16:10:11 +000039 %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
40 %a = load i32, i32 addrspace(1)* %in
41 %b = load i32, i32 addrspace(1)* %b_ptr
42 %c = tail call i32 @defined_function(i32 %b) nounwind
43 %result = add i32 %a, %c
44 store i32 %result, i32 addrspace(1)* %out
45 ret void
46}
Matt Arsenault0b386362016-12-15 20:50:12 +000047
48define i32 @test_tail_call_ret() {
49 %call = call i32 @external_function(i32 10)
50 ret i32 %call
51}
52
53declare i32 @extern_variadic(...)
54
55define i32 @test_tail_call_bitcast_extern_variadic(<4 x float> %arg0, <4 x float> %arg1, i32 %arg2) {
56 %add = fadd <4 x float> %arg0, %arg1
57 %call = tail call i32 bitcast (i32 (...)* @extern_variadic to i32 (<4 x float>)*)(<4 x float> %add) #7
58 ret i32 %call
59}