1 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -stack-protector 2 -emit-llvm -o - %s | FileCheck %s
2
3 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -stack-protector 2 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
4 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
5
6 // Check that function attributes are added to the OpenMP runtime functions.
7
8 template <class T>
9 struct S {
10 T f;
SS11 S(T a) : f(a) {}
SS12 S() : f() {}
operator TS13 operator T() { return T(); }
~SS14 ~S() {}
15 };
16
17 // CHECK: define internal void @.omp.copyprivate.copy_func(i8* %0, i8* %1) [[ATTR0:#[0-9]+]] {
18
19 void foo0();
20
foo1()21 int foo1() {
22 char a;
23
24 #pragma omp parallel
25 a = 2;
26 #pragma omp single copyprivate(a)
27 foo0();
28
29 return 0;
30 }
31
32 // CHECK: define internal void @.omp_task_privates_map.({{.*}}) [[ATTR3:#[0-9]+]] {
33 // CHECK: define internal i32 @.omp_task_entry.({{.*}}) [[ATTR0]] {
34 // CHECK: define internal i32 @.omp_task_destructor.({{.*}}) [[ATTR0]] {
35
foo2()36 int foo2() {
37 S<double> s_arr[] = {1, 2};
38 S<double> var(3);
39 #pragma omp task private(s_arr, var)
40 s_arr[0] = var;
41 return 0;
42 }
43
44 // CHECK: define internal void @.omp.reduction.reduction_func(i8* %0, i8* %1) [[ATTR0]] {
45
foo3(int n,float * a,float * b)46 float foo3(int n, float *a, float *b) {
47 int i;
48 float result;
49
50 #pragma omp parallel for private(i) reduction(+:result)
51 for (i=0; i < n; i++)
52 result = result + (a[i] * b[i]);
53 return result;
54 }
55
56 // CHECK: attributes [[ATTR0]] = {{{.*}} sspstrong {{.*}}}
57 // CHECK: attributes [[ATTR3]] = {{{.*}} sspstrong {{.*}}}
58