| 1 |
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=60 -x c++ -emit-llvm %s -o - | FileCheck %s |
| 2 |
// expected-no-diagnostics |
| 3 |
#ifndef HEADER |
| 4 |
#define HEADER |
| 5 |
|
| 6 |
int global; |
| 7 |
#define VECTOR_SIZE 4 |
| 8 |
|
| 9 |
int main (int argc, char **argv) { |
| 10 |
int i,n; |
| 11 |
int x; |
| 12 |
|
| 13 |
n = VECTOR_SIZE; |
| 14 |
|
| 15 |
#pragma omp parallel masked firstprivate(x) num_threads(2) |
| 16 |
{ |
| 17 |
int *xPtr = nullptr; |
| 18 |
// scalar |
| 19 |
#pragma omp task default(shared:scalar) |
| 20 |
{ |
| 21 |
xPtr = &x; |
| 22 |
} |
| 23 |
#pragma omp taskwait |
| 24 |
|
| 25 |
// pointer |
| 26 |
#pragma omp task default(shared:pointer) shared(x) |
| 27 |
{ |
| 28 |
xPtr = &x; |
| 29 |
} |
| 30 |
#pragma omp taskwait |
| 31 |
} |
| 32 |
|
| 33 |
int *aggregate[VECTOR_SIZE] = {0,0,0,0}; |
| 34 |
|
| 35 |
#pragma omp parallel masked num_threads(2) |
| 36 |
{ |
| 37 |
// aggregate |
| 38 |
#pragma omp task default(shared:aggregate) |
| 39 |
for(i=0;i<n;i++) { |
| 40 |
aggregate[i] = &x; |
| 41 |
} |
| 42 |
#pragma omp taskwait |
| 43 |
|
| 44 |
#pragma omp task default(shared:aggregate) shared(x) |
| 45 |
for(i=0;i<n;i++) { |
| 46 |
aggregate[i] = &x; |
| 47 |
} |
| 48 |
#pragma omp taskwait |
| 49 |
|
| 50 |
// all |
| 51 |
#pragma omp task default(shared:all) |
| 52 |
for(i=0;i<n;i++) { |
| 53 |
aggregate[i] = &x; |
| 54 |
} |
| 55 |
#pragma omp taskwait |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
#endif |
| 60 |
|
| 61 |
// CHECK-LABEL: define {{.*}}main.omp_outlined{{.*}} |
| 62 |
// CHECK: store ptr null, ptr{{.*}} |
| 63 |
// CHECK-NEXT: {{.*}}getelementptr {{.*}} |
| 64 |
// CHECK-NEXT: store ptr {{.*}} |
| 65 |
// CHECK-NEXT: {{.*}}getelementptr {{.*}} |
| 66 |
// CHECK-NEXT: store ptr {{.*}} |
| 67 |
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}} |
| 68 |
// CHECK: ret void |
| 69 |
// |
| 70 |
// CHECK: define {{.*}}main.omp_outlined{{.*}} |
| 71 |
// CHECK: {{.*}}getelementptr {{.*}} |
| 72 |
// CHECK-NEXT: store ptr {{.*}} |
| 73 |
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}} |
| 74 |
// CHECK: store ptr {{.*}} |
| 75 |
// CHECK-NEXT: {{.*}}getelementptr {{.*}} |
| 76 |
// CHECK-NEXT: store ptr {{.*}} |
| 77 |
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}} |
| 78 |
// CHECK: store ptr {{.*}} |
| 79 |
// CHECK-NEXT: {{.*}}getelementptr {{.*}} |
| 80 |
// CHECK-NEXT: store ptr {{.*}} |
| 81 |
// CHECK-NEXT: {{.*}}getelementptr {{.*}} |
| 82 |
// CHECK-NEXT: store ptr {{.*}} |
| 83 |
// CHECK-NEXT: {{.*}}getelementptr {{.*}} |
| 84 |
// CHECK-NEXT: store ptr {{.*}} |
| 85 |
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}} |
| 86 |
// CHECK: ret void |