[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / CodeGenOpenCL / visibility.cl
blobaddfe33377f9396ef9a9add20cab08e1419dd6f4
1 // RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility=default -triple amdgcn-unknown-unknown -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-DEFAULT %s
2 // RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility=protected -triple amdgcn-unknown-unknown -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-PROTECTED %s
3 // RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility=hidden -triple amdgcn-unknown-unknown -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-HIDDEN %s
5 // REQUIRES: amdgpu-registered-target
7 // FVIS-DEFAULT: @glob ={{.*}} local_unnamed_addr addrspace(1) global i32 0
8 // FVIS-PROTECTED: @glob = protected local_unnamed_addr
9 // FVIS-HIDDEN: @glob = hidden local_unnamed_addr
10 int glob = 0;
11 // FVIS-DEFAULT: @glob_hidden = hidden local_unnamed_addr
12 // FVIS-PROTECTED: @glob_hidden = hidden local_unnamed_addr
13 // FVIS-HIDDEN: @glob_hidden = hidden local_unnamed_addr
14 __attribute__((visibility("hidden"))) int glob_hidden = 0;
15 // FVIS-DEFAULT: @glob_protected = protected local_unnamed_addr
16 // FVIS-PROTECTED: @glob_protected = protected local_unnamed_addr
17 // FVIS-HIDDEN: @glob_protected = protected local_unnamed_addr
18 __attribute__((visibility("protected"))) int glob_protected = 0;
19 // FVIS-DEFAULT: @glob_default ={{( dso_local)?}} local_unnamed_addr
20 // FVIS-PROTECTED: @glob_default ={{( dso_local)?}} local_unnamed_addr
21 // FVIS-HIDDEN: @glob_default ={{( dso_local)?}} local_unnamed_addr
22 __attribute__((visibility("default"))) int glob_default = 0;
24 // FVIS-DEFAULT: @ext = external local_unnamed_addr
25 // FVIS-PROTECTED: @ext = external protected local_unnamed_addr
26 // FVIS-HIDDEN: @ext = external hidden local_unnamed_addr
27 extern int ext;
28 // FVIS-DEFAULT: @ext_hidden = external hidden local_unnamed_addr
29 // FVIS-PROTECTED: @ext_hidden = external hidden local_unnamed_addr
30 // FVIS-HIDDEN: @ext_hidden = external hidden local_unnamed_addr
31 __attribute__((visibility("hidden"))) extern int ext_hidden;
32 // FVIS-DEFAULT: @ext_protected = external protected local_unnamed_addr
33 // FVIS-PROTECTED: @ext_protected = external protected local_unnamed_addr
34 // FVIS-HIDDEN: @ext_protected = external protected local_unnamed_addr
35 __attribute__((visibility("protected"))) extern int ext_protected;
36 // FVIS-DEFAULT: @ext_default = external local_unnamed_addr
37 // FVIS-PROTECTED: @ext_default = external local_unnamed_addr
38 // FVIS-HIDDEN: @ext_default = external local_unnamed_addr
39 __attribute__((visibility("default"))) extern int ext_default;
41 // FVIS-DEFAULT: define{{.*}} amdgpu_kernel void @kern()
42 // FVIS-PROTECTED: define protected amdgpu_kernel void @kern()
43 // FVIS-HIDDEN: define protected amdgpu_kernel void @kern()
44 kernel void kern() {}
45 // FVIS-DEFAULT: define protected amdgpu_kernel void @kern_hidden()
46 // FVIS-PROTECTED: define protected amdgpu_kernel void @kern_hidden()
47 // FVIS-HIDDEN: define protected amdgpu_kernel void @kern_hidden()
48 __attribute__((visibility("hidden"))) kernel void kern_hidden() {}
49 // FVIS-DEFAULT: define protected amdgpu_kernel void @kern_protected()
50 // FVIS-PROTECTED: define protected amdgpu_kernel void @kern_protected()
51 // FVIS-HIDDEN: define protected amdgpu_kernel void @kern_protected()
52 __attribute__((visibility("protected"))) kernel void kern_protected() {}
53 // FVIS-DEFAULT: define{{.*}} amdgpu_kernel void @kern_default()
54 // FVIS-PROTECTED: define{{.*}} amdgpu_kernel void @kern_default()
55 // FVIS-HIDDEN: define{{.*}} amdgpu_kernel void @kern_default()
56 __attribute__((visibility("default"))) kernel void kern_default() {}
58 // FVIS-DEFAULT: define{{.*}} void @func()
59 // FVIS-PROTECTED: define protected void @func()
60 // FVIS-HIDDEN: define hidden void @func()
61 void func() {}
62 // FVIS-DEFAULT: define hidden void @func_hidden()
63 // FVIS-PROTECTED: define hidden void @func_hidden()
64 // FVIS-HIDDEN: define hidden void @func_hidden()
65 __attribute__((visibility("hidden"))) void func_hidden() {}
66 // FVIS-DEFAULT: define protected void @func_protected()
67 // FVIS-PROTECTED: define protected void @func_protected()
68 // FVIS-HIDDEN: define protected void @func_protected()
69 __attribute__((visibility("protected"))) void func_protected() {}
70 // FVIS-DEFAULT: define{{.*}} void @func_default()
71 // FVIS-PROTECTED: define{{.*}} void @func_default()
72 // FVIS-HIDDEN: define{{.*}} void @func_default()
73 __attribute__((visibility("default"))) void func_default() {}
75 extern kernel void ext_kern();
76 __attribute__((visibility("hidden"))) extern kernel void ext_kern_hidden();
77 __attribute__((visibility("protected"))) extern kernel void ext_kern_protected();
78 __attribute__((visibility("default"))) extern kernel void ext_kern_default();
80 extern void ext_func();
81 __attribute__((visibility("hidden"))) extern void ext_func_hidden();
82 __attribute__((visibility("protected"))) extern void ext_func_protected();
83 __attribute__((visibility("default"))) extern void ext_func_default();
85 void use() {
86 glob = ext + ext_hidden + ext_protected + ext_default;
87 ext_kern();
88 ext_kern_hidden();
89 ext_kern_protected();
90 ext_kern_default();
91 ext_func();
92 ext_func_hidden();
93 ext_func_protected();
94 ext_func_default();
97 // FVIS-DEFAULT: declare amdgpu_kernel void @ext_kern()
98 // FVIS-PROTECTED: declare protected amdgpu_kernel void @ext_kern()
99 // FVIS-HIDDEN: declare protected amdgpu_kernel void @ext_kern()
101 // FVIS-DEFAULT: declare protected amdgpu_kernel void @ext_kern_hidden()
102 // FVIS-PROTECTED: declare protected amdgpu_kernel void @ext_kern_hidden()
103 // FVIS-HIDDEN: declare protected amdgpu_kernel void @ext_kern_hidden()
105 // FVIS-DEFAULT: declare protected amdgpu_kernel void @ext_kern_protected()
106 // FVIS-PROTECTED: declare protected amdgpu_kernel void @ext_kern_protected()
107 // FVIS-HIDDEN: declare protected amdgpu_kernel void @ext_kern_protected()
109 // FVIS-DEFAULT: declare amdgpu_kernel void @ext_kern_default()
110 // FVIS-PROTECTED: declare amdgpu_kernel void @ext_kern_default()
111 // FVIS-HIDDEN: declare amdgpu_kernel void @ext_kern_default()
114 // FVIS-DEFAULT: declare void @ext_func()
115 // FVIS-PROTECTED: declare protected void @ext_func()
116 // FVIS-HIDDEN: declare hidden void @ext_func()
118 // FVIS-DEFAULT: declare hidden void @ext_func_hidden()
119 // FVIS-PROTECTED: declare hidden void @ext_func_hidden()
120 // FVIS-HIDDEN: declare hidden void @ext_func_hidden()
122 // FVIS-DEFAULT: declare protected void @ext_func_protected()
123 // FVIS-PROTECTED: declare protected void @ext_func_protected()
124 // FVIS-HIDDEN: declare protected void @ext_func_protected()
126 // FVIS-DEFAULT: declare void @ext_func_default()
127 // FVIS-PROTECTED: declare void @ext_func_default()
128 // FVIS-HIDDEN: declare void @ext_func_default()