1 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin10.6.0 -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10.6.0 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
5 // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -x c++ -std=c++11 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
8 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
9 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -x c++ -std=c++11 -emit-pch -o %t %s
10 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10.6.0 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
11 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
12 // RUN: %clang_cc1 -fopenmp-simd -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -x c++ -std=c++11 -emit-pch -o %t %s
13 // RUN: %clang_cc1 -fopenmp-simd -fnoopenmp-use-tls -triple x86_64-unknown-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
14 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
15 // expected-no-diagnostics
20 enum omp_allocator_handle_t
{
21 omp_null_allocator
= 0,
22 omp_default_mem_alloc
= 1,
23 omp_large_cap_mem_alloc
= 2,
24 omp_const_mem_alloc
= 3,
25 omp_high_bw_mem_alloc
= 4,
26 omp_low_lat_mem_alloc
= 5,
27 omp_cgroup_mem_alloc
= 6,
28 omp_pteam_mem_alloc
= 7,
29 omp_thread_mem_alloc
= 8,
30 KMP_ALLOCATOR_MAX_HANDLE
= __UINTPTR_MAX__
40 #pragma omp allocate(b) allocator(omp_default_mem_alloc)
44 #pragma omp allocate(a) allocator(omp_large_cap_mem_alloc)
45 #pragma omp allocate(b) allocator(omp_const_mem_alloc)
46 #pragma omp allocate(d, c) allocator(omp_high_bw_mem_alloc)
51 #pragma omp allocate(m) allocator(omp_low_lat_mem_alloc)
54 template <class T
> T
foo() {
56 #pragma omp allocate(v) allocator(omp_cgroup_mem_alloc)
64 #pragma omp allocate(ns::a) allocator(omp_pteam_mem_alloc)
66 // CHECK-NOT: call {{.+}} {{__kmpc_alloc|__kmpc_free}}
70 #pragma omp allocate(a) allocator(omp_thread_mem_alloc)
73 #pragma omp allocate(b)
77 // CHECK-LABEL: define {{[^@]+}}@main
78 // CHECK-SAME: () #[[ATTR0:[0-9]+]] {
80 // CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
81 // CHECK-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
82 // CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4
83 // CHECK-NEXT: store i32 2, ptr @_ZZ4mainE1a, align 4
84 // CHECK-NEXT: [[DOTB__VOID_ADDR:%.*]] = call ptr @__kmpc_alloc(i32 [[TMP0]], i64 8, ptr null)
85 // CHECK-NEXT: store double 3.000000e+00, ptr [[DOTB__VOID_ADDR]], align 8
86 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_Z3fooIiET_v()
87 // CHECK-NEXT: store i32 [[CALL]], ptr [[RETVAL]], align 4
88 // CHECK-NEXT: call void @__kmpc_free(i32 [[TMP0]], ptr [[DOTB__VOID_ADDR]], ptr null)
89 // CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
90 // CHECK-NEXT: ret i32 [[TMP2]]
92 // CHECK: define {{.*}}i32 @{{.+}}foo{{.+}}()
93 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(ptr @{{.+}})
94 // CHECK-NEXT: [[V_VOID_ADDR:%.+]] = call ptr @__kmpc_alloc(i32 [[GTID]], i64 4, ptr inttoptr (i64 6 to ptr))
95 // CHECK-NOT: {{__kmpc_alloc|__kmpc_free}}
96 // CHECK: store i32 %{{.+}}, ptr [[V_VOID_ADDR]],
97 // CHECK-NEXT: [[V_VAL:%.+]] = load i32, ptr [[V_VOID_ADDR]],
98 // CHECK-NEXT: call void @__kmpc_free(i32 [[GTID]], ptr [[V_VOID_ADDR]], ptr inttoptr (i64 6 to ptr))
99 // CHECK-NOT: {{__kmpc_alloc|__kmpc_free}}
100 // CHECK: ret i32 [[V_VAL]]
102 // CHECK-NOT: call {{.+}} {{__kmpc_alloc|__kmpc_free}}
103 extern template int ST
<int>::m
;
105 // CHECK: define{{.*}} void @{{.+}}bar{{.+}}(i32 noundef %{{.+}}, ptr noundef {{.+}})
106 void bar(int a
, float &z
) {
107 // CHECK: [[A_VOID_PTR:%.+]] = call ptr @__kmpc_alloc(i32 [[GTID:%.+]], i64 4, ptr inttoptr (i64 1 to ptr))
108 // CHECK: store i32 %{{.+}}, ptr [[A_VOID_PTR]],
109 // CHECK: [[Z_VOID_PTR:%.+]] = call ptr @__kmpc_alloc(i32 [[GTID]], i64 8, ptr inttoptr (i64 1 to ptr))
110 // CHECK: store ptr %{{.+}}, ptr [[Z_VOID_PTR]],
111 #pragma omp allocate(a, z) allocator(omp_default_mem_alloc)
112 // CHECK: call void @__kmpc_free(i32 [[GTID]], ptr [[Z_VOID_PTR]], ptr inttoptr (i64 1 to ptr))
113 // CHECK: call void @__kmpc_free(i32 [[GTID]], ptr [[A_VOID_PTR]], ptr inttoptr (i64 1 to ptr))