1 // REQUIRES: amdgpu-registered-target
3 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s
5 // Derived from CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu by deleting references to HOST
6 // The original test passes the result through opt O2, but that seems to introduce invalid
7 // addrspace casts which are not being fixed as part of the present change.
9 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel1Pi(ptr {{.*}} %x)
10 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
11 __attribute__((amdgpu_kernel
)) void kernel1(int *x
) {
15 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel2Ri(ptr {{.*}} nonnull align 4 dereferenceable(4) %x)
16 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
17 __attribute__((amdgpu_kernel
)) void kernel2(int &x
) {
21 // CHECK-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel3PU3AS2iPU3AS1i(ptr addrspace(2){{.*}} %x, ptr addrspace(1){{.*}} %y)
22 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
23 __attribute__((amdgpu_kernel
)) void kernel3(__attribute__((address_space(2))) int *x
,
24 __attribute__((address_space(1))) int *y
) {
28 // COMMON-LABEL: define{{.*}} void @_Z4funcPi(ptr{{.*}} %x)
29 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
30 __attribute__((amdgpu_kernel
)) void func(int *x
) {
38 // `by-val` struct is passed by-indirect-alias (a mix of by-ref and indirect
39 // by-val). However, the enhanced address inferring pass should be able to
40 // assume they are global pointers.
43 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel41S(ptr addrspace(4){{.*}} byref(%struct.S) align 8 %0)
44 __attribute__((amdgpu_kernel
)) void kernel4(struct S s
) {
49 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel5P1S(ptr {{.*}} %s)
50 __attribute__((amdgpu_kernel
)) void kernel5(struct S
*s
) {
58 // `by-val` array is passed by-indirect-alias (a mix of by-ref and indirect
59 // by-val). However, the enhanced address inferring pass should be able to
60 // assume they are global pointers.
62 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel61T(ptr addrspace(4){{.*}} byref(%struct.T) align 8 %0)
63 __attribute__((amdgpu_kernel
)) void kernel6(struct T t
) {
68 // Check that coerced pointers retain the noalias attribute when qualified with __restrict.
69 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel7Pi(ptr noalias{{.*}} %x)
70 __attribute__((amdgpu_kernel
)) void kernel7(int *__restrict x
) {
74 // Single element struct.
78 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel82SS(ptr %a.coerce)
79 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
80 __attribute__((amdgpu_kernel
)) void kernel8(struct SS a
) {