• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4 
5 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
6 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
8 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
9 // expected-no-diagnostics
10 #ifndef HEADER
11 #define HEADER
12 
13 // CHECK: [[PRIVATES:%.+]] = type { i8*, i8* }
14 
15 struct S {
16   int a;
SS17   S() : a(0) {}
SS18   S(const S&) {}
operator =S19   S& operator=(const S&) {return *this;}
~SS20   ~S() {}
operator +(const S & a,const S & b)21   friend S operator+(const S&a, const S&b) {return a;}
22 };
23 
24 
main(int argc,char ** argv)25 int main(int argc, char **argv) {
26   int a;
27   float b;
28   S c[5];
29   short d[argc];
30 #pragma omp taskgroup task_reduction(+: a, b, argc)
31   {
32 #pragma omp taskgroup task_reduction(-:c, d)
33 #pragma omp parallel
34 #pragma omp master taskloop in_reduction(+:a) in_reduction(-:d)
35     for (int i = 0; i < 5; ++i)
36       a += d[a];
37   }
38   return 0;
39 }
40 
41 // CHECK-LABEL: @main
42 // CHECK:       void @__kmpc_taskgroup(%struct.ident_t* @1, i32 [[GTID:%.+]])
43 // CHECK:       [[TD1:%.+]] = call i8* @__kmpc_taskred_init(i32 [[GTID]], i32 3, i8* %
44 // CHECK-NEXT:  store i8* [[TD1]], i8** [[TD1_ADDR:%[^,]+]],
45 // CHECK-NEXT:  call void @__kmpc_taskgroup(%struct.ident_t* @1, i32 [[GTID]])
46 // CHECK:       [[TD2:%.+]] = call i8* @__kmpc_taskred_init(i32 [[GTID]], i32 2, i8* %
47 // CHECK-NEXT:  store i8* [[TD2]], i8** [[TD2_ADDR:%[^,]+]],
48 // CHECK-NEXT:  call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @1, i32 5, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*, i64, i16*, i8**, i8**)* [[OMP_PARALLEL:@.+]] to void (i32*, i32*, ...)*), i32* %{{.+}}, i64 %{{.+}}, i16* %{{.+}}, i8** [[TD1_ADDR]], i8** [[TD2_ADDR]])
49 // CHECK-NEXT:  call void @__kmpc_end_taskgroup(%struct.ident_t* @1, i32 [[GTID]])
50 // CHECK-NEXT:  call void @__kmpc_end_taskgroup(%struct.ident_t* @1, i32 [[GTID]])
51 
52 // CHECK:       define internal void [[OMP_PARALLEL]](
53 // CHECK:       [[RES:%.+]] = call {{.*}}i32 @__kmpc_master(
54 // CHECK-NEXT:  [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
55 // CHECK-NEXT:  br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
56 // CHECK:       [[THEN]]
57 // CHECK:       [[TASK_T:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @1, i32 [[GTID:%.+]], i32 1, i64 96, i64 40, i32 (i32, i8*)* bitcast (i32 (i32, [[T:%.+]]*)* [[OMP_TASK:@.+]] to i32 (i32, i8*)*))
58 // CHECK-NEXT:  [[TASK_T_WITH_PRIVS:%.+]] = bitcast i8* [[TASK_T]] to [[T]]*
59 // CHECK:       [[PRIVS:%.+]] = getelementptr inbounds [[T]], [[T]]* [[TASK_T_WITH_PRIVS]], i32 0, i32 1
60 // CHECK:       [[TD1_REF:%.+]] = getelementptr inbounds [[PRIVATES]], [[PRIVATES]]* [[PRIVS]], i32 0, i32 0
61 // CHECK-NEXT:  [[TD1:%.+]] = load i8*, i8** %{{.+}},
62 // CHECK-NEXT:  store i8* [[TD1]], i8** [[TD1_REF]],
63 // CHECK-NEXT:  [[TD2_REF:%.+]] = getelementptr inbounds [[PRIVATES]], [[PRIVATES]]* [[PRIVS]], i32 0, i32 1
64 // CHECK-NEXT:  [[TD2:%.+]] = load i8*, i8** %{{.+}},
65 // CHECK-NEXT:  store i8* [[TD2]], i8** [[TD2_REF]],
66 // CHECK:       call void @__kmpc_taskloop(%struct.ident_t* @1, i32 [[GTID]], i8* [[TASK_T]], i32 1,
67 // CHECK:  call {{.*}}void @__kmpc_end_master(
68 // CHECK-NEXT:  br label {{%?}}[[EXIT]]
69 // CHECK:       [[EXIT]]
70 // CHECK:       ret void
71 // CHECK-NEXT:  }
72 
73 // CHECK:       define internal {{.*}} [[OMP_TASK]](
74 // CHECK:       call void (i8*, ...) %{{[^(]+}}(i8* %{{.+}}, i8*** [[TD1_REF:%[^,]+]], i8*** [[TD2_REF:%[^,]+]])
75 // CHECK-NEXT:  [[TD1_ADDR:%.+]] = load i8**, i8*** [[TD1_REF]],
76 // CHECK-NEXT:  [[TD2_ADDR:%.+]] = load i8**, i8*** [[TD2_REF]],
77 // CHECK-NEXT:  [[A_REF:%.+]] = getelementptr inbounds %
78 // CHECK-NEXT:  [[A_ADDR:%.+]] = load i32*, i32** [[A_REF]],
79 // CHECK-NEXT:  [[TD1:%.+]] = load i8*, i8** [[TD1_ADDR]],
80 // CHECK-NEXT:  [[GTID:%.+]] = load i32, i32* %
81 // CHECK-NEXT:  [[A_PTR:%.+]] = bitcast i32* [[A_ADDR]] to i8*
82 // CHECK-NEXT:  call i8* @__kmpc_task_reduction_get_th_data(i32 [[GTID]], i8* [[TD1]], i8* [[A_PTR]])
83 // CHECK:       [[D_REF:%.+]] = getelementptr inbounds %
84 // CHECK-NEXT:  [[D_ADDR:%.+]] = load i16*, i16** [[D_REF]],
85 // CHECK:       [[TD2:%.+]] = load i8*, i8** [[TD2_ADDR]],
86 // CHECK-NEXT:  [[D_PTR:%.+]] = bitcast i16* [[D_ADDR]] to i8*
87 // CHECK-NEXT:  call i8* @__kmpc_task_reduction_get_th_data(i32 [[GTID]], i8* [[TD2]], i8* [[D_PTR]])
88 // CHECK:       add nsw i32
89 // CHECK:       store i32 %
90 #endif
91