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