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