1 // add -fopenmp-targets
2 
3 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
4 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
5 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
6 
7 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
8 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
9 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
10 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
11 // expected-no-diagnostics
12 #ifndef HEADER
13 #define HEADER
14 
15 typedef __INTPTR_TYPE__ intptr_t;
16 
17 // CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
18 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
19 // CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
20 
21 void foo();
22 
23 struct S {
24   intptr_t a, b, c;
SS25   S(intptr_t a) : a(a) {}
operator charS26   operator char() { return a; }
~SS27   ~S() {}
28 };
29 
30 template <typename T>
tmain()31 T tmain() {
32 #pragma omp target
33 #pragma omp teams distribute parallel for simd proc_bind(master)
34   for(int i = 0; i < 1000; i++) {}
35   return T();
36 }
37 
main()38 int main() {
39   // CHECK-LABEL: @main
40 #pragma omp target
41 #pragma omp teams distribute parallel for simd proc_bind(spread)
42   for(int i = 0; i < 1000; i++) {}
43 #pragma omp target
44 #pragma omp teams distribute parallel for simd proc_bind(close)
45   for(int i = 0; i < 1000; i++) {}
46   return tmain<int>();
47 }
48 
49 // CHECK: call {{.*}}@__tgt_target_teams_mapper(%struct.ident_t* @{{.+}}, {{.+}})
50 // CHECK: call void [[OFFL1:@.+]]()
51 // CHECK: call {{.*}}@__tgt_target_teams_mapper(%struct.ident_t* @{{.+}}, {{.+}})
52 // CHECK: call void [[OFFL2:@.+]]()
53 // CHECK: [[CALL_RET:%.+]] = call{{.+}} i32 [[TMAIN:@.+]]()
54 // CHECK: ret i32 [[CALL_RET]]
55 
56 // CHECK: define{{.+}} void [[OFFL1]](
57 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}}* [[OMP_OUTLINED_1:@.+]] to {{.+}})
58 
59 // CHECK: define{{.+}} [[OMP_OUTLINED_1]](i32* {{.+}} [[GTID_IN:%.+]],
60 // CHECK: [[GTID_ADDR:%.+]] = alloca i32*,
61 // CHECK: store i32* [[GTID_IN]], i32** [[GTID_ADDR]],
62 // CHECK: [[GTID_REF:%.+]] = load i32*, i32** [[GTID_ADDR]],
63 // CHECK: [[GTID_VAL:%.+]] = load i32, i32* [[GTID_REF]],
64 // CHECK: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID_VAL]], i32 4)
65 // CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
66 // CHECK: ret void
67 
68 // CHECK: define{{.+}} [[OFFL2]]()
69 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}}* [[OMP_OUTLINED_1:@.+]] to {{.+}})
70 
71 // CHECK: define{{.+}} [[OMP_OUTLINED_1]](i32* {{.+}} [[GTID_IN:%.+]],
72 // CHECK: [[GTID_ADDR:%.+]] = alloca i32*,
73 // CHECK: store i32* [[GTID_IN]], i32** [[GTID_ADDR]],
74 // CHECK: [[GTID_REF:%.+]] = load i32*, i32** [[GTID_ADDR]],
75 // CHECK: [[GTID_VAL:%.+]] = load i32, i32* [[GTID_REF]],
76 // CHECK: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID_VAL]], i32 3)
77 // CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
78 // CHECK: ret void
79 
80 // CHECK: define{{.+}} [[TMAIN]]()
81 // CHECK: call {{.*}}@__tgt_target_teams_mapper(%struct.ident_t* @{{.+}}, {{.+}})
82 // CHECK: call void [[OFFL3:@.+]]()
83 
84 // CHECK: define{{.+}} [[OFFL3]]()
85 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}}* [[OMP_OUTLINED_3:@.+]] to {{.+}})
86 
87 // CHECK: define{{.+}} [[OMP_OUTLINED_3]](i32* {{.+}} [[GTID_IN:%.+]],
88 // CHECK: [[GTID_ADDR:%.+]] = alloca i32*,
89 // CHECK: store i32* [[GTID_IN]], i32** [[GTID_ADDR]],
90 // CHECK: [[GTID_REF:%.+]] = load i32*, i32** [[GTID_ADDR]],
91 // CHECK: [[GTID_VAL:%.+]] = load i32, i32* [[GTID_REF]],
92 // CHECK: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID_VAL]], i32 2)
93 // CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
94 // CHECK: ret void
95 
96 // CHECK: !{!"llvm.loop.vectorize.enable", i1 true}
97 
98 #endif
99