1 // NOTE
: Assertions have been autogenerated by utils
/update_cc_test_checks.py UTC_ARGS
: --version
5
2 // RUN
: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std
=CL1.2 \
3 // RUN
: -emit-llvm -o - | FileCheck --check-prefixes
=OPENCL12 %s
4 // RUN
: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std
=CL2.0 \
5 // RUN
: -emit-llvm -o - | FileCheck --check-prefixes
=OPENCL20 %s
6 // RUN
: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std
=CL3.0 \
7 // RUN
: -emit-llvm -o - | FileCheck --check-prefixes
=OPENCL30 %s
8 // RUN
: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std
=CL3.0 -cl-ext
=+__opencl_c_generic_address_space \
9 // RUN
: -emit-llvm -o - | FileCheck --check-prefixes
=OPENCL30GAS %s
11 // OPENCL-LABEL
: define dso_local void
@test1_builtin_alloca
(
12 // OPENCL-SAME
: i32 noundef
[[N
:%.
*]]) #[[ATTR0
:[0-
9]+]] {
13 // OPENCL-NEXT
: [[ENTRY
:.
*:]]
14 // OPENCL-NEXT
: [[N_ADDR
:%.
*]] = alloca i32
, align
4, addrspace
(5)
15 // OPENCL-NEXT
: [[ALLOC_PTR
:%.
*]] = alloca ptr addrspace
(5), align
4, addrspace
(5)
16 // OPENCL-NEXT
: store i32
[[N]], ptr addrspace(5) [[N_ADDR]], align 4
17 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
18 // OPENCL-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
19 // OPENCL-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
20 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
21 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align 4
22 // OPENCL-NEXT: ret void
23 // OPENCL12-LABEL: define dso_local void @test1_builtin_alloca(
24 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0:[0-9]+]] {
25 // OPENCL12-NEXT: [[ENTRY:.*:]]
26 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
27 // OPENCL12-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
28 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace
(5) [[N_ADDR]], align 4
29 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align
4
30 // OPENCL12-NEXT
: [[CONV
:%.
*]] = zext i32
[[TMP0]] to i64
31 // OPENCL12-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
32 // OPENCL12-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
33 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align 4
34 // OPENCL12-NEXT: ret void
36 // OPENCL20-LABEL: define dso_local void @test1_builtin_alloca(
37 // OPENCL20-SAME: i32 noundef [[N:%.*]]) #[[ATTR0:[0-9]+]] {
38 // OPENCL20-NEXT: [[ENTRY:.*:]]
39 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
40 // OPENCL20-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
41 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
42 // OPENCL20-NEXT: [[ALLOC_PTR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR]] to ptr
43 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
44 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
45 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
46 // OPENCL20-NEXT
: [[MUL
:%.
*]] = mul i64
[[CONV]], 4
47 // OPENCL20-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
48 // OPENCL20-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ASCAST]], align 4
49 // OPENCL20-NEXT: ret void
51 // OPENCL30-LABEL: define dso_local void @test1_builtin_alloca(
52 // OPENCL30-SAME: i32 noundef [[N:%.*]]) #[[ATTR0:[0-9]+]] {
53 // OPENCL30-NEXT: [[ENTRY:.*:]]
54 // OPENCL30-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
55 // OPENCL30-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
56 // OPENCL30-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
57 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
58 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
59 // OPENCL30-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
60 // OPENCL30-NEXT
: [[TMP1
:%.
*]] = alloca i8
, i64
[[MUL]], align 8, addrspace(5)
61 // OPENCL30-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align 4
62 // OPENCL30-NEXT: ret void
64 // OPENCL30GAS-LABEL: define dso_local void @test1_builtin_alloca(
65 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0:[0-9]+]] {
66 // OPENCL30GAS-NEXT: [[ENTRY:.*:]]
67 // OPENCL30GAS-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
68 // OPENCL30GAS-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
69 // OPENCL30GAS-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
70 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR]] to ptr
71 // OPENCL30GAS-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
72 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
73 // OPENCL30GAS-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
74 // OPENCL30GAS-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
75 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align
8, addrspace
(5)
76 // OPENCL30GAS-NEXT
: store ptr addrspace
(5) [[TMP1]], ptr [[ALLOC_PTR_ASCAST]], align 4
77 // OPENCL30GAS-NEXT: ret void
79 void test1_builtin_alloca(unsigned n) {
80 __private float* alloc_ptr = (__private float*)__builtin_alloca(n*sizeof(int));
83 // OPENCL-LABEL: define dso_local void @test1_builtin_alloca_uninitialized(
84 // OPENCL-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
85 // OPENCL-NEXT: [[ENTRY:.*:]]
86 // OPENCL-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
87 // OPENCL-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
88 // OPENCL-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
89 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
90 // OPENCL-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
91 // OPENCL-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
92 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
93 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace
(5) [[ALLOC_PTR_UNINITIALIZED]], align 4
94 // OPENCL-NEXT: ret void
95 // OPENCL12-LABEL: define dso_local void @test1_builtin_alloca_uninitialized(
96 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
97 // OPENCL12-NEXT: [[ENTRY:.*:]]
98 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
99 // OPENCL12-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
100 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
101 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
102 // OPENCL12-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
103 // OPENCL12-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
104 // OPENCL12-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
105 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]], align
4
106 // OPENCL12-NEXT
: ret void
108 // OPENCL20-LABEL
: define dso_local void
@test1_builtin_alloca_uninitialized
(
109 // OPENCL20-SAME
: i32 noundef
[[N
:%.
*]]) #[[ATTR0]] {
110 // OPENCL20-NEXT: [[ENTRY:.*:]]
111 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
112 // OPENCL20-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
113 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
114 // OPENCL20-NEXT: [[ALLOC_PTR_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]] to ptr
115 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
116 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
117 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
118 // OPENCL20-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
119 // OPENCL20-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
120 // OPENCL20-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_UNINITIALIZED_ASCAST]], align 4
121 // OPENCL20-NEXT: ret void
123 // OPENCL30-LABEL: define dso_local void @test1_builtin_alloca_uninitialized(
124 // OPENCL30-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
125 // OPENCL30-NEXT
: [[ENTRY
:.
*:]]
126 // OPENCL30-NEXT
: [[N_ADDR
:%.
*]] = alloca i32
, align
4, addrspace
(5)
127 // OPENCL30-NEXT
: [[ALLOC_PTR_UNINITIALIZED
:%.
*]] = alloca ptr addrspace
(5), align
4, addrspace
(5)
128 // OPENCL30-NEXT
: store i32
[[N]], ptr addrspace(5) [[N_ADDR]], align 4
129 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
130 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
131 // OPENCL30-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
132 // OPENCL30-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
133 // OPENCL30-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]], align 4
134 // OPENCL30-NEXT: ret void
136 // OPENCL30GAS-LABEL: define dso_local void @test1_builtin_alloca_uninitialized(
137 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
138 // OPENCL30GAS-NEXT: [[ENTRY:.*:]]
139 // OPENCL30GAS-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
140 // OPENCL30GAS-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
141 // OPENCL30GAS-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
142 // OPENCL30GAS-NEXT: [[ALLOC_PTR_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]] to ptr
143 // OPENCL30GAS-NEXT: store i32 [[N]], ptr
[[N_ADDR_ASCAST]], align 4
144 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align
4
145 // OPENCL30GAS-NEXT
: [[CONV
:%.
*]] = zext i32
[[TMP0]] to i64
146 // OPENCL30GAS-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
147 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 8, addrspace(5)
148 // OPENCL30GAS-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_UNINITIALIZED_ASCAST]], align 4
149 // OPENCL30GAS-NEXT: ret void
151 void test1_builtin_alloca_uninitialized(unsigned n) {
152 __private float* alloc_ptr_uninitialized = (__private float*)__builtin_alloca_uninitialized(n*sizeof(int));
155 // OPENCL-LABEL: define dso_local void @test1_builtin_alloca_with_align(
156 // OPENCL-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
157 // OPENCL-NEXT: [[ENTRY:.*:]]
158 // OPENCL-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
159 // OPENCL-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
160 // OPENCL-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
161 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
162 // OPENCL-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
163 // OPENCL-NEXT
: [[MUL
:%.
*]] = mul i64
[[CONV]], 4
164 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 1, addrspace(5)
165 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN]], align 4
166 // OPENCL-NEXT: ret void
167 // OPENCL12-LABEL: define dso_local void @test1_builtin_alloca_with_align(
168 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
169 // OPENCL12-NEXT: [[ENTRY:.*:]]
170 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
171 // OPENCL12-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
172 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
173 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
174 // OPENCL12-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
175 // OPENCL12-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
176 // OPENCL12-NEXT
: [[TMP1
:%.
*]] = alloca i8
, i64
[[MUL]], align 1, addrspace(5)
177 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN]], align 4
178 // OPENCL12-NEXT: ret void
180 // OPENCL20-LABEL: define dso_local void @test1_builtin_alloca_with_align(
181 // OPENCL20-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
182 // OPENCL20-NEXT: [[ENTRY:.*:]]
183 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
184 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
185 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
186 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN]] to ptr
187 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
188 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
189 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
190 // OPENCL20-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
191 // OPENCL20-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align
1, addrspace
(5)
192 // OPENCL20-NEXT
: store ptr addrspace
(5) [[TMP1]], ptr [[ALLOC_PTR_ALIGN_ASCAST]], align 4
193 // OPENCL20-NEXT: ret void
195 // OPENCL30-LABEL: define dso_local void @test1_builtin_alloca_with_align(
196 // OPENCL30-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
197 // OPENCL30-NEXT: [[ENTRY:.*:]]
198 // OPENCL30-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
199 // OPENCL30-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
200 // OPENCL30-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
201 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
202 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
203 // OPENCL30-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
204 // OPENCL30-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 1, addrspace(5)
205 // OPENCL30-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace
(5) [[ALLOC_PTR_ALIGN]], align 4
206 // OPENCL30-NEXT: ret void
208 // OPENCL30GAS-LABEL: define dso_local void @test1_builtin_alloca_with_align(
209 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
210 // OPENCL30GAS-NEXT: [[ENTRY:.*:]]
211 // OPENCL30GAS-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
212 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
213 // OPENCL30GAS-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
214 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ALIGN_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN]] to ptr
215 // OPENCL30GAS-NEXT
: store i32
[[N]], ptr [[N_ADDR_ASCAST]], align 4
216 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
217 // OPENCL30GAS-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
218 // OPENCL30GAS-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
219 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 1, addrspace(5)
220 // OPENCL30GAS-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ALIGN_ASCAST]], align 4
221 // OPENCL30GAS-NEXT: ret void
223 void test1_builtin_alloca_with_align(unsigned n) {
224 __private float* alloc_ptr_align = (__private float*)__builtin_alloca_with_align((n*sizeof(int)), 8);
227 // OPENCL-LABEL: define dso_local void @test1_builtin_alloca_with_align_uninitialized(
228 // OPENCL-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
229 // OPENCL-NEXT: [[ENTRY:.*:]]
230 // OPENCL-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
231 // OPENCL-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
232 // OPENCL-NEXT: store i32 [[N]], ptr addrspace
(5) [[N_ADDR]], align 4
233 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align
4
234 // OPENCL-NEXT
: [[CONV
:%.
*]] = zext i32
[[TMP0]] to i64
235 // OPENCL-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
236 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 1, addrspace(5)
237 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]], align 4
238 // OPENCL-NEXT: ret void
239 // OPENCL12-LABEL: define dso_local void @test1_builtin_alloca_with_align_uninitialized(
240 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
241 // OPENCL12-NEXT: [[ENTRY:.*:]]
242 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
243 // OPENCL12-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
244 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
245 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
246 // OPENCL12-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
247 // OPENCL12-NEXT
: [[MUL
:%.
*]] = mul i64
[[CONV]], 4
248 // OPENCL12-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 1, addrspace(5)
249 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]], align 4
250 // OPENCL12-NEXT: ret void
252 // OPENCL20-LABEL: define dso_local void @test1_builtin_alloca_with_align_uninitialized(
253 // OPENCL20-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
254 // OPENCL20-NEXT: [[ENTRY:.*:]]
255 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
256 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
257 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
258 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]] to ptr
259 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
260 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
261 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
262 // OPENCL20-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
263 // OPENCL20-NEXT
: [[TMP1
:%.
*]] = alloca i8
, i64
[[MUL]], align 1, addrspace(5)
264 // OPENCL20-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST]], align 4
265 // OPENCL20-NEXT: ret void
267 // OPENCL30-LABEL: define dso_local void @test1_builtin_alloca_with_align_uninitialized(
268 // OPENCL30-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
269 // OPENCL30-NEXT: [[ENTRY:.*:]]
270 // OPENCL30-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
271 // OPENCL30-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
272 // OPENCL30-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
273 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
274 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
275 // OPENCL30-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
276 // OPENCL30-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align
1, addrspace
(5)
277 // OPENCL30-NEXT
: store ptr addrspace
(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]], align 4
278 // OPENCL30-NEXT: ret void
280 // OPENCL30GAS-LABEL: define dso_local void @test1_builtin_alloca_with_align_uninitialized(
281 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
282 // OPENCL30GAS-NEXT: [[ENTRY:.*:]]
283 // OPENCL30GAS-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
284 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
285 // OPENCL30GAS-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
286 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]] to ptr
287 // OPENCL30GAS-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
288 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
289 // OPENCL30GAS-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
290 // OPENCL30GAS-NEXT: [[MUL:%.*]] = mul i64 [[CONV]], 4
291 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[MUL]], align 1, addrspace(5)
292 // OPENCL30GAS-NEXT: store ptr addrspace(5) [[TMP1]], ptr
[[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST]], align 4
293 // OPENCL30GAS-NEXT: ret void
295 void test1_builtin_alloca_with_align_uninitialized(unsigned n) {
296 __private float* alloc_ptr_align_uninitialized = (__private float*)__builtin_alloca_with_align_uninitialized((n*sizeof(int)), 8);
299 // OPENCL-LABEL: define dso_local void @test2_builtin_alloca(
300 // OPENCL-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
301 // OPENCL-NEXT: [[ENTRY:.*:]]
302 // OPENCL-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
303 // OPENCL-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
304 // OPENCL-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
305 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
306 // OPENCL-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
307 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
308 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align 4
309 // OPENCL-NEXT: ret void
310 // OPENCL12-LABEL: define dso_local void @test2_builtin_alloca(
311 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
312 // OPENCL12-NEXT: [[ENTRY:.*:]]
313 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
314 // OPENCL12-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
315 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
316 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
317 // OPENCL12-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
318 // OPENCL12-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
319 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align 4
320 // OPENCL12-NEXT: ret void
322 // OPENCL20-LABEL: define dso_local void @test2_builtin_alloca(
323 // OPENCL20-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
324 // OPENCL20-NEXT: [[ENTRY:.*:]]
325 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
326 // OPENCL20-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
327 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
328 // OPENCL20-NEXT: [[ALLOC_PTR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR]] to ptr
329 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
330 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
331 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
332 // OPENCL20-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
333 // OPENCL20-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ASCAST]], align 4
334 // OPENCL20-NEXT: ret void
336 // OPENCL30-LABEL: define dso_local void @test2_builtin_alloca(
337 // OPENCL30-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
338 // OPENCL30-NEXT: [[ENTRY:.*:]]
339 // OPENCL30-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
340 // OPENCL30-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
341 // OPENCL30-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
342 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
343 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
344 // OPENCL30-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
345 // OPENCL30-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align 4
346 // OPENCL30-NEXT: ret void
348 // OPENCL30GAS-LABEL: define dso_local void @test2_builtin_alloca(
349 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
350 // OPENCL30GAS-NEXT: [[ENTRY:.*:]]
351 // OPENCL30GAS-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
352 // OPENCL30GAS-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
353 // OPENCL30GAS-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
354 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR]] to ptr
355 // OPENCL30GAS-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
356 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
357 // OPENCL30GAS-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
358 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
359 // OPENCL30GAS-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ASCAST]], align 4
360 // OPENCL30GAS-NEXT: ret void
362 void test2_builtin_alloca(unsigned n) {
363 __private void *alloc_ptr = __builtin_alloca(n);
366 // OPENCL-LABEL: define dso_local void @test2_builtin_alloca_uninitialized(
367 // OPENCL-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
368 // OPENCL-NEXT: [[ENTRY:.*:]]
369 // OPENCL-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
370 // OPENCL-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
371 // OPENCL-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
372 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
373 // OPENCL-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
374 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
375 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]], align 4
376 // OPENCL-NEXT: ret void
377 // OPENCL12-LABEL: define dso_local void @test2_builtin_alloca_uninitialized(
378 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
379 // OPENCL12-NEXT: [[ENTRY:.*:]]
380 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
381 // OPENCL12-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
382 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
383 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
384 // OPENCL12-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
385 // OPENCL12-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
386 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]], align 4
387 // OPENCL12-NEXT: ret void
389 // OPENCL20-LABEL: define dso_local void @test2_builtin_alloca_uninitialized(
390 // OPENCL20-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
391 // OPENCL20-NEXT: [[ENTRY:.*:]]
392 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
393 // OPENCL20-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
394 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
395 // OPENCL20-NEXT: [[ALLOC_PTR_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]] to ptr
396 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
397 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
398 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
399 // OPENCL20-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
400 // OPENCL20-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_UNINITIALIZED_ASCAST]], align 4
401 // OPENCL20-NEXT: ret void
403 // OPENCL30-LABEL: define dso_local void @test2_builtin_alloca_uninitialized(
404 // OPENCL30-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
405 // OPENCL30-NEXT: [[ENTRY:.*:]]
406 // OPENCL30-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
407 // OPENCL30-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
408 // OPENCL30-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
409 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
410 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
411 // OPENCL30-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
412 // OPENCL30-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]], align 4
413 // OPENCL30-NEXT: ret void
415 // OPENCL30GAS-LABEL: define dso_local void @test2_builtin_alloca_uninitialized(
416 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
417 // OPENCL30GAS-NEXT: [[ENTRY:.*:]]
418 // OPENCL30GAS-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
419 // OPENCL30GAS-NEXT: [[ALLOC_PTR_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
420 // OPENCL30GAS-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
421 // OPENCL30GAS-NEXT: [[ALLOC_PTR_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_UNINITIALIZED]] to ptr
422 // OPENCL30GAS-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
423 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
424 // OPENCL30GAS-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
425 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 8, addrspace(5)
426 // OPENCL30GAS-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_UNINITIALIZED_ASCAST]], align 4
427 // OPENCL30GAS-NEXT: ret void
429 void test2_builtin_alloca_uninitialized(unsigned n) {
430 __private void *alloc_ptr_uninitialized = __builtin_alloca_uninitialized(n);
433 // OPENCL-LABEL: define dso_local void @test2_builtin_alloca_with_align(
434 // OPENCL-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
435 // OPENCL-NEXT: [[ENTRY:.*:]]
436 // OPENCL-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
437 // OPENCL-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
438 // OPENCL-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
439 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
440 // OPENCL-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
441 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
442 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN]], align 4
443 // OPENCL-NEXT: ret void
444 // OPENCL12-LABEL: define dso_local void @test2_builtin_alloca_with_align(
445 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
446 // OPENCL12-NEXT: [[ENTRY:.*:]]
447 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
448 // OPENCL12-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
449 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
450 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
451 // OPENCL12-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
452 // OPENCL12-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
453 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN]], align 4
454 // OPENCL12-NEXT: ret void
456 // OPENCL20-LABEL: define dso_local void @test2_builtin_alloca_with_align(
457 // OPENCL20-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
458 // OPENCL20-NEXT: [[ENTRY:.*:]]
459 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
460 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
461 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
462 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN]] to ptr
463 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
464 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
465 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
466 // OPENCL20-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
467 // OPENCL20-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ALIGN_ASCAST]], align 4
468 // OPENCL20-NEXT: ret void
470 // OPENCL30-LABEL: define dso_local void @test2_builtin_alloca_with_align(
471 // OPENCL30-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
472 // OPENCL30-NEXT: [[ENTRY:.*:]]
473 // OPENCL30-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
474 // OPENCL30-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
475 // OPENCL30-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
476 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
477 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
478 // OPENCL30-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
479 // OPENCL30-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN]], align 4
480 // OPENCL30-NEXT: ret void
482 // OPENCL30GAS-LABEL: define dso_local void @test2_builtin_alloca_with_align(
483 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
484 // OPENCL30GAS-NEXT: [[ENTRY:.*:]]
485 // OPENCL30GAS-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
486 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ALIGN:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
487 // OPENCL30GAS-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
488 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ALIGN_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN]] to ptr
489 // OPENCL30GAS-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
490 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
491 // OPENCL30GAS-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
492 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
493 // OPENCL30GAS-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ALIGN_ASCAST]], align 4
494 // OPENCL30GAS-NEXT: ret void
496 void test2_builtin_alloca_with_align(unsigned n) {
497 __private void *alloc_ptr_align = __builtin_alloca_with_align(n, 8);
500 // OPENCL-LABEL: define dso_local void @test2_builtin_alloca_with_align_uninitialized(
501 // OPENCL-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
502 // OPENCL-NEXT: [[ENTRY:.*:]]
503 // OPENCL-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
504 // OPENCL-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
505 // OPENCL-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
506 // OPENCL-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
507 // OPENCL-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
508 // OPENCL-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
509 // OPENCL-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]], align 4
510 // OPENCL-NEXT: ret void
511 // OPENCL12-LABEL: define dso_local void @test2_builtin_alloca_with_align_uninitialized(
512 // OPENCL12-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
513 // OPENCL12-NEXT: [[ENTRY:.*:]]
514 // OPENCL12-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
515 // OPENCL12-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
516 // OPENCL12-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
517 // OPENCL12-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
518 // OPENCL12-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
519 // OPENCL12-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
520 // OPENCL12-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]], align 4
521 // OPENCL12-NEXT: ret void
523 // OPENCL20-LABEL: define dso_local void @test2_builtin_alloca_with_align_uninitialized(
524 // OPENCL20-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
525 // OPENCL20-NEXT: [[ENTRY:.*:]]
526 // OPENCL20-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
527 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
528 // OPENCL20-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[N_ADDR]] to ptr
529 // OPENCL20-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]] to ptr
530 // OPENCL20-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
531 // OPENCL20-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
532 // OPENCL20-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
533 // OPENCL20-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
534 // OPENCL20-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST]], align
4
535 // OPENCL20-NEXT
: ret void
537 // OPENCL30-LABEL
: define dso_local void
@test2_builtin_alloca_with_align_uninitialized
(
538 // OPENCL30-SAME
: i32 noundef
[[N
:%.
*]]) #[[ATTR0]] {
539 // OPENCL30-NEXT: [[ENTRY:.*:]]
540 // OPENCL30-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
541 // OPENCL30-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
542 // OPENCL30-NEXT: store i32 [[N]], ptr addrspace(5) [[N_ADDR]], align 4
543 // OPENCL30-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
544 // OPENCL30-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
545 // OPENCL30-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
546 // OPENCL30-NEXT: store ptr addrspace(5) [[TMP1]], ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]], align 4
547 // OPENCL30-NEXT: ret void
549 // OPENCL30GAS-LABEL: define dso_local void @test2_builtin_alloca_with_align_uninitialized(
550 // OPENCL30GAS-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
551 // OPENCL30GAS-NEXT
: [[ENTRY
:.
*:]]
552 // OPENCL30GAS-NEXT
: [[N_ADDR
:%.
*]] = alloca i32
, align
4, addrspace
(5)
553 // OPENCL30GAS-NEXT
: [[ALLOC_PTR_ALIGN_UNINITIALIZED
:%.
*]] = alloca ptr addrspace
(5), align
4, addrspace
(5)
554 // OPENCL30GAS-NEXT
: [[N_ADDR_ASCAST
:%.
*]] = addrspacecast ptr addrspace
(5) [[N_ADDR]] to ptr
555 // OPENCL30GAS-NEXT: [[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[ALLOC_PTR_ALIGN_UNINITIALIZED]] to ptr
556 // OPENCL30GAS-NEXT: store i32 [[N]], ptr [[N_ADDR_ASCAST]], align 4
557 // OPENCL30GAS-NEXT: [[TMP0:%.*]] = load i32, ptr [[N_ADDR_ASCAST]], align 4
558 // OPENCL30GAS-NEXT: [[CONV:%.*]] = zext i32 [[TMP0]] to i64
559 // OPENCL30GAS-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[CONV]], align 1, addrspace(5)
560 // OPENCL30GAS-NEXT: store ptr addrspace(5) [[TMP1]], ptr [[ALLOC_PTR_ALIGN_UNINITIALIZED_ASCAST]], align 4
561 // OPENCL30GAS-NEXT: ret void
563 void test2_builtin_alloca_with_align_uninitialized(unsigned n) {
564 __private void *alloc_ptr_align_uninitialized = __builtin_alloca_with_align_uninitialized(n, 8);