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: define{{.*}} amdgpu_kernel void @_Z6kernelv() #[[ATTR:[0-9]+]]
10 __attribute__((amdgpu_kernel
, amdgpu_flat_work_group_size(1, 256))) void
13 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel1Pi(ptr {{.*}} %x)
14 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
15 __attribute__((amdgpu_kernel
)) void kernel1(int *x
) {
19 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel2Ri(ptr {{.*}} nonnull align 4 dereferenceable(4) %x)
20 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
21 __attribute__((amdgpu_kernel
)) void kernel2(int &x
) {
25 // CHECK-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel3PU3AS2iPU3AS1i(ptr addrspace(2){{.*}} %x, ptr addrspace(1){{.*}} %y)
26 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
27 __attribute__((amdgpu_kernel
)) void kernel3(__attribute__((address_space(2))) int *x
,
28 __attribute__((address_space(1))) int *y
) {
32 // COMMON-LABEL: define{{.*}} void @_Z4funcPi(ptr{{.*}} %x)
33 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
34 __attribute__((amdgpu_kernel
)) void func(int *x
) {
42 // `by-val` struct is passed by-indirect-alias (a mix of by-ref and indirect
43 // by-val). However, the enhanced address inferring pass should be able to
44 // assume they are global pointers.
47 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel41S(ptr addrspace(4){{.*}} byref(%struct.S) align 8 %0)
48 __attribute__((amdgpu_kernel
)) void kernel4(struct S s
) {
53 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel5P1S(ptr {{.*}} %s)
54 __attribute__((amdgpu_kernel
)) void kernel5(struct S
*s
) {
62 // `by-val` array is passed by-indirect-alias (a mix of by-ref and indirect
63 // by-val). However, the enhanced address inferring pass should be able to
64 // assume they are global pointers.
66 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel61T(ptr addrspace(4){{.*}} byref(%struct.T) align 8 %0)
67 __attribute__((amdgpu_kernel
)) void kernel6(struct T t
) {
72 // Check that coerced pointers retain the noalias attribute when qualified with __restrict.
73 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel7Pi(ptr noalias{{.*}} %x)
74 __attribute__((amdgpu_kernel
)) void kernel7(int *__restrict x
) {
78 // Single element struct.
82 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel82SS(ptr %a.coerce)
83 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr
84 __attribute__((amdgpu_kernel
)) void kernel8(struct SS a
) {
88 // COMMON: attributes #[[ATTR]] = { {{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}} }