| 1 |
// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device \ |
| 2 |
// RUN: -emit-llvm -o - -x hip %s \ |
| 3 |
// RUN: | FileCheck -check-prefixes=DEV,NORDC %s |
| 4 |
// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device \ |
| 5 |
// RUN: -fgpu-rdc -cuid=abc -emit-llvm -o - -x hip %s \ |
| 6 |
// RUN: | FileCheck -check-prefixes=DEV,RDC %s |
| 7 |
// RUN: %clang_cc1 -triple x86_64-unknown-gnu-linux \ |
| 8 |
// RUN: -emit-llvm -o - -x hip %s \ |
| 9 |
// RUN: | FileCheck -check-prefixes=HOST,NORDC-H %s |
| 10 |
// RUN: %clang_cc1 -triple x86_64-unknown-gnu-linux \ |
| 11 |
// RUN: -fgpu-rdc -cuid=abc -emit-llvm -o - -x hip %s \ |
| 12 |
// RUN: | FileCheck -check-prefixes=HOST,RDC-H %s |
| 13 |
// RUN: %clang_cc1 -triple nvptx -fcuda-is-device \ |
| 14 |
// RUN: -fgpu-rdc -cuid=abc -emit-llvm -o - %s \ |
| 15 |
// RUN: | FileCheck -check-prefixes=CUDA %s |
| 16 |
|
| 17 |
#include "Inputs/cuda.h" |
| 18 |
|
| 19 |
// DEV-DAG: @v1 = addrspace(1) externally_initialized global i32 0 |
| 20 |
// NORDC-H-DAG: @v1 = internal global i32 undef |
| 21 |
// RDC-H-DAG: @v1 = global i32 undef |
| 22 |
__device__ int v1; |
| 23 |
// DEV-DAG: @v2 = addrspace(4) externally_initialized constant i32 0 |
| 24 |
// NORDC-H-DAG: @v2 = internal global i32 undef |
| 25 |
// RDC-H-DAG: @v2 = global i32 undef |
| 26 |
__constant__ int v2; |
| 27 |
// DEV-DAG: @v3 = addrspace(1) externally_initialized global ptr addrspace(1) null |
| 28 |
// NORDC-H-DAG: @v3 = internal externally_initialized global ptr null |
| 29 |
// RDC-H-DAG: @v3 = externally_initialized global ptr null |
| 30 |
#if __HIP__ |
| 31 |
__managed__ int v3; |
| 32 |
#endif |
| 33 |
|
| 34 |
// DEV-DAG: @ev1 = external addrspace(1) global i32 |
| 35 |
// HOST-DAG: @ev1 = external global i32 |
| 36 |
extern __device__ int ev1; |
| 37 |
// DEV-DAG: @ev2 = external addrspace(4) global i32 |
| 38 |
// HOST-DAG: @ev2 = external global i32 |
| 39 |
extern __constant__ int ev2; |
| 40 |
// DEV-DAG: @ev3 = external addrspace(1) externally_initialized global ptr addrspace(1) |
| 41 |
// HOST-DAG: @ev3 = external externally_initialized global ptr |
| 42 |
#if __HIP__ |
| 43 |
extern __managed__ int ev3; |
| 44 |
#endif |
| 45 |
|
| 46 |
// NORDC-DAG: @_ZL3sv1 = addrspace(1) externally_initialized global i32 0 |
| 47 |
// RDC-DAG: @_ZL3sv1.static.[[HASH:.*]] = addrspace(1) externally_initialized global i32 0 |
| 48 |
// HOST-DAG: @_ZL3sv1 = internal global i32 undef |
| 49 |
// CUDA-DAG: @_ZL3sv1__static__[[HASH:.*]] = addrspace(1) externally_initialized global i32 0 |
| 50 |
static __device__ int sv1; |
| 51 |
// NORDC-DAG: @_ZL3sv2 = addrspace(4) externally_initialized constant i32 0 |
| 52 |
// RDC-DAG: @_ZL3sv2.static.[[HASH]] = addrspace(4) externally_initialized constant i32 0 |
| 53 |
// HOST-DAG: @_ZL3sv2 = internal global i32 undef |
| 54 |
// CUDA-DAG: @_ZL3sv2__static__[[HASH]] = addrspace(4) externally_initialized constant i32 0 |
| 55 |
static __constant__ int sv2; |
| 56 |
// NORDC-DAG: @_ZL3sv3 = addrspace(1) externally_initialized global ptr addrspace(1) null |
| 57 |
// RDC-DAG: @_ZL3sv3.static.[[HASH]] = addrspace(1) externally_initialized global ptr addrspace(1) null |
| 58 |
// HOST-DAG: @_ZL3sv3 = internal externally_initialized global ptr null |
| 59 |
#if __HIP__ |
| 60 |
static __managed__ int sv3; |
| 61 |
#endif |
| 62 |
|
| 63 |
__device__ __host__ int work(int *x); |
| 64 |
|
| 65 |
__device__ __host__ int fun1() { |
| 66 |
return work(&ev1) + work(&ev2) + work(&sv1) + work(&sv2) |
| 67 |
#if __HIP__ |
| 68 |
+ work(&ev3) + work(&sv3) |
| 69 |
#endif |
| 70 |
; |
| 71 |
} |
| 72 |
|
| 73 |
// HOST: hipRegisterVar({{.*}}@v1 |
| 74 |
// HOST: hipRegisterVar({{.*}}@v2 |
| 75 |
// HOST: hipRegisterManagedVar({{.*}}@v3 |
| 76 |
// HOST-NOT: hipRegisterVar({{.*}}@ev1 |
| 77 |
// HOST-NOT: hipRegisterVar({{.*}}@ev2 |
| 78 |
// HOST-NOT: hipRegisterManagedVar({{.*}}@ev3 |
| 79 |
// HOST: hipRegisterVar({{.*}}@_ZL3sv1 |
| 80 |
// HOST: hipRegisterVar({{.*}}@_ZL3sv2 |
| 81 |
// HOST: hipRegisterManagedVar({{.*}}@_ZL3sv3 |