================
@@ -0,0 +1,86 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
UTC_ARGS: --version 5
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL1.2 -emit-llvm
-o - | FileCheck --check-prefix=OPENCL12 %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL2.0 -emit-llvm
-o - | FileCheck --check-prefix=OPENCL20 %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 -emit-llvm
-o - | FileCheck --check-prefix=OPENCL30 %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck
--check-prefix=OPENCL30-EXT %s
+
+// OPENCL12-LABEL: define dso_local ptr addrspace(5) @test1(
+// OPENCL12-SAME: ) #[[ATTR0:[0-9]+]] {
+// OPENCL12-NEXT: [[ENTRY:.*:]]
+// OPENCL12-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4,
addrspace(5)
+// OPENCL12-NEXT: [[TMP0:%.*]] = alloca i8, i64 128, align 8, addrspace(5)
+// OPENCL12-NEXT: store ptr addrspace(5) [[TMP0]], ptr addrspace(5)
[[ALLOC_PTR]], align 4
+// OPENCL12-NEXT: [[TMP1:%.*]] = load ptr addrspace(5), ptr addrspace(5)
[[ALLOC_PTR]], align 4
+// OPENCL12-NEXT: ret ptr addrspace(5) [[TMP1]]
+//
+// OPENCL20-LABEL: define dso_local ptr @test1(
+// OPENCL20-SAME: ) #[[ATTR0:[0-9]+]] {
+// OPENCL20-NEXT: [[ENTRY:.*:]]
+// OPENCL20-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr, align 8, addrspace(5)
+// OPENCL20-NEXT: [[TMP0:%.*]] = alloca i8, i64 128, align 8, addrspace(5)
+// OPENCL20-NEXT: [[TMP1:%.*]] = addrspacecast ptr addrspace(5) [[TMP0]] to
ptr
+// OPENCL20-NEXT: store ptr [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align
8
+// OPENCL20-NEXT: [[TMP2:%.*]] = load ptr, ptr addrspace(5) [[ALLOC_PTR]],
align 8
+// OPENCL20-NEXT: ret ptr [[TMP2]]
+//
+// OPENCL30-LABEL: define dso_local ptr addrspace(5) @test1(
+// OPENCL30-SAME: ) #[[ATTR0:[0-9]+]] {
+// OPENCL30-NEXT: [[ENTRY:.*:]]
+// OPENCL30-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4,
addrspace(5)
+// OPENCL30-NEXT: [[TMP0:%.*]] = alloca i8, i64 128, align 8, addrspace(5)
+// OPENCL30-NEXT: store ptr addrspace(5) [[TMP0]], ptr addrspace(5)
[[ALLOC_PTR]], align 4
+// OPENCL30-NEXT: [[TMP1:%.*]] = load ptr addrspace(5), ptr addrspace(5)
[[ALLOC_PTR]], align 4
+// OPENCL30-NEXT: ret ptr addrspace(5) [[TMP1]]
+//
+// OPENCL30-EXT-LABEL: define dso_local ptr @test1(
+// OPENCL30-EXT-SAME: ) #[[ATTR0:[0-9]+]] {
+// OPENCL30-EXT-NEXT: [[ENTRY:.*:]]
+// OPENCL30-EXT-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr, align 8, addrspace(5)
+// OPENCL30-EXT-NEXT: [[TMP0:%.*]] = alloca i8, i64 128, align 8,
addrspace(5)
+// OPENCL30-EXT-NEXT: [[TMP1:%.*]] = addrspacecast ptr addrspace(5)
[[TMP0]] to ptr
+// OPENCL30-EXT-NEXT: store ptr [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]],
align 8
+// OPENCL30-EXT-NEXT: [[TMP2:%.*]] = load ptr, ptr addrspace(5)
[[ALLOC_PTR]], align 8
+// OPENCL30-EXT-NEXT: ret ptr [[TMP2]]
+//
+float* test1() {
+ float* alloc_ptr = (float*)__builtin_alloca(32 * sizeof(int));
+ return alloc_ptr;
+}
+
+// OPENCL12-LABEL: define dso_local void @test2(
+// OPENCL12-SAME: ) #[[ATTR0]] {
+// OPENCL12-NEXT: [[ENTRY:.*:]]
+// OPENCL12-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4,
addrspace(5)
+// OPENCL12-NEXT: [[TMP0:%.*]] = alloca i8, i64 28, align 8, addrspace(5)
+// OPENCL12-NEXT: store ptr addrspace(5) [[TMP0]], ptr addrspace(5)
[[ALLOC_PTR]], align 4
+// OPENCL12-NEXT: ret void
+//
+// OPENCL20-LABEL: define dso_local void @test2(
+// OPENCL20-SAME: ) #[[ATTR0]] {
+// OPENCL20-NEXT: [[ENTRY:.*:]]
+// OPENCL20-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr, align 8, addrspace(5)
+// OPENCL20-NEXT: [[TMP0:%.*]] = alloca i8, i64 28, align 8, addrspace(5)
+// OPENCL20-NEXT: [[TMP1:%.*]] = addrspacecast ptr addrspace(5) [[TMP0]] to
ptr
+// OPENCL20-NEXT: store ptr [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]], align
8
+// OPENCL20-NEXT: ret void
+//
+// OPENCL30-LABEL: define dso_local void @test2(
+// OPENCL30-SAME: ) #[[ATTR0]] {
+// OPENCL30-NEXT: [[ENTRY:.*:]]
+// OPENCL30-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr addrspace(5), align 4,
addrspace(5)
+// OPENCL30-NEXT: [[TMP0:%.*]] = alloca i8, i64 28, align 8, addrspace(5)
+// OPENCL30-NEXT: store ptr addrspace(5) [[TMP0]], ptr addrspace(5)
[[ALLOC_PTR]], align 4
+// OPENCL30-NEXT: ret void
+//
+// OPENCL30-EXT-LABEL: define dso_local void @test2(
+// OPENCL30-EXT-SAME: ) #[[ATTR0]] {
+// OPENCL30-EXT-NEXT: [[ENTRY:.*:]]
+// OPENCL30-EXT-NEXT: [[ALLOC_PTR:%.*]] = alloca ptr, align 8, addrspace(5)
+// OPENCL30-EXT-NEXT: [[TMP0:%.*]] = alloca i8, i64 28, align 8,
addrspace(5)
+// OPENCL30-EXT-NEXT: [[TMP1:%.*]] = addrspacecast ptr addrspace(5)
[[TMP0]] to ptr
+// OPENCL30-EXT-NEXT: store ptr [[TMP1]], ptr addrspace(5) [[ALLOC_PTR]],
align 8
+// OPENCL30-EXT-NEXT: ret void
+//
+void test2() {
+ void *alloc_ptr = __builtin_alloca(28);
----------------
arsenm wrote:
Also test the other flavors of __builtin_alloca, like
__builtin_alloca_with_align etc.
https://github.com/llvm/llvm-project/pull/95750
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits