brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 8df1d75 Raw
89 lines · cpp
1// REQUIRES: amdgpu-registered-target2 3// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s4 5// Derived from CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu by deleting references to HOST6// The original test passes the result through opt O2, but that seems to introduce invalid7// addrspace casts which are not being fixed as part of the present change.8 9// COMMON: define{{.*}} amdgpu_kernel void @_Z6kernelv() #[[ATTR:[0-9]+]]10__attribute__((amdgpu_kernel, amdgpu_flat_work_group_size(1, 256))) void11    kernel() {}12 13// COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel1Pi(ptr {{.*}} %x)14// CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr15__attribute__((amdgpu_kernel)) void kernel1(int *x) {16  x[0]++;17}18 19// COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel2Ri(ptr {{.*}} nonnull align 4 dereferenceable(4) %x)20// CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr21__attribute__((amdgpu_kernel)) void kernel2(int &x) {22  x++;23}24 25// CHECK-LABEL: define{{.*}} amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(ptr addrspace(2){{.*}} %x, ptr addrspace(1){{.*}} %y)26// CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr27__attribute__((amdgpu_kernel)) void kernel3(__attribute__((address_space(2))) int *x,28                                            __attribute__((address_space(1))) int *y) {29  y[0] = x[0];30}31 32// COMMON-LABEL: define{{.*}} void @_Z4funcPi(ptr{{.*}} %x)33// CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr34__attribute__((amdgpu_kernel)) void func(int *x) {35  x[0]++;36}37 38struct S {39  int *x;40  float *y;41};42// `by-val` struct is passed by-indirect-alias (a mix of by-ref and indirect43// by-val). However, the enhanced address inferring pass should be able to44// assume they are global pointers.45//46 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) {49  s.x[0]++;50  s.y[0] += 1.f;51}52 53// COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel5P1S(ptr {{.*}} %s)54__attribute__((amdgpu_kernel)) void kernel5(struct S *s) {55  s->x[0]++;56  s->y[0] += 1.f;57}58 59struct T {60  float *x[2];61};62// `by-val` array is passed by-indirect-alias (a mix of by-ref and indirect63// by-val). However, the enhanced address inferring pass should be able to64// assume they are global pointers.65//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) {68  t.x[0][0] += 1.f;69  t.x[1][0] += 2.f;70}71 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) {75  x[0]++;76}77 78// Single element struct.79struct SS {80  float *x;81};82// COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel82SS(ptr %a.coerce)83// CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to ptr84__attribute__((amdgpu_kernel)) void kernel8(struct SS a) {85  *a.x += 3.f;86}87 88// COMMON: attributes #[[ATTR]] = { {{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}} }89