Matt Arsenault | 9430b91 | 2016-05-18 16:10:11 +0000 | [diff] [blame] | 1 | ; 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 Arsenault | 1635387 | 2014-04-22 16:42:00 +0000 | [diff] [blame] | 4 | |
Oliver Stannard | 7e7d983 | 2016-02-02 13:52:43 +0000 | [diff] [blame] | 5 | ; CHECK: in function test_call_external{{.*}}: unsupported call to function external_function |
Matt Arsenault | 9430b91 | 2016-05-18 16:10:11 +0000 | [diff] [blame] | 6 | ; 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 Arsenault | 0b38636 | 2016-12-15 20:50:12 +0000 | [diff] [blame] | 8 | ; CHECK: in function test_tail_call_bitcast_extern_variadic{{.*}}: unsupported call to function extern_variadic |
Matt Arsenault | 1635387 | 2014-04-22 16:42:00 +0000 | [diff] [blame] | 9 | |
| 10 | |
| 11 | declare i32 @external_function(i32) nounwind |
| 12 | |
Matt Arsenault | 3dbeefa | 2017-03-21 21:39:51 +0000 | [diff] [blame] | 13 | define amdgpu_kernel void @test_call_external(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { |
Matt Arsenault | deaef8e | 2015-04-22 17:10:44 +0000 | [diff] [blame] | 14 | %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 Arsenault | 1635387 | 2014-04-22 16:42:00 +0000 | [diff] [blame] | 23 | define i32 @defined_function(i32 %x) nounwind noinline { |
| 24 | %y = add i32 %x, 8 |
| 25 | ret i32 %y |
| 26 | } |
| 27 | |
Matt Arsenault | 3dbeefa | 2017-03-21 21:39:51 +0000 | [diff] [blame] | 28 | define amdgpu_kernel void @test_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 29 | %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 30 | %a = load i32, i32 addrspace(1)* %in |
| 31 | %b = load i32, i32 addrspace(1)* %b_ptr |
Matt Arsenault | 1635387 | 2014-04-22 16:42:00 +0000 | [diff] [blame] | 32 | %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 Arsenault | 9430b91 | 2016-05-18 16:10:11 +0000 | [diff] [blame] | 37 | |
Matt Arsenault | 3dbeefa | 2017-03-21 21:39:51 +0000 | [diff] [blame] | 38 | define amdgpu_kernel void @test_tail_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { |
Matt Arsenault | 9430b91 | 2016-05-18 16:10:11 +0000 | [diff] [blame] | 39 | %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 Arsenault | 0b38636 | 2016-12-15 20:50:12 +0000 | [diff] [blame] | 47 | |
| 48 | define i32 @test_tail_call_ret() { |
| 49 | %call = call i32 @external_function(i32 10) |
| 50 | ret i32 %call |
| 51 | } |
| 52 | |
| 53 | declare i32 @extern_variadic(...) |
| 54 | |
| 55 | define 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 | } |