1 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s
2 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-PROTECTED %s
3 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility hidden -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-HIDDEN %s
4
5 #include "Inputs/cuda.h"
6
7 // CHECK-DEFAULT: @c = addrspace(4) externally_initialized global
8 // CHECK-DEFAULT: @g = addrspace(1) externally_initialized global
9 // CHECK-PROTECTED: @c = protected addrspace(4) externally_initialized global
10 // CHECK-PROTECTED: @g = protected addrspace(1) externally_initialized global
11 // CHECK-HIDDEN: @c = protected addrspace(4) externally_initialized global
12 // CHECK-HIDDEN: @g = protected addrspace(1) externally_initialized global
13 __constant__ int c;
14 __device__ int g;
15
16 // CHECK-DEFAULT: @e = external addrspace(1) global
17 // CHECK-PROTECTED: @e = external protected addrspace(1) global
18 // CHECK-HIDDEN: @e = external protected addrspace(1) global
19 extern __device__ int e;
20
21 // dummy one to hold reference to `e`.
f()22 __device__ int f() {
23 return e;
24 }
25
26 // CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov()
27 // CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov()
28 // CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov()
foo()29 __global__ void foo() {
30 g = c;
31 }
32