1 // expected-no-diagnostics 2 #ifndef HEADER 3 #define HEADER 4 5 // Test host codegen. 6 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 7 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s 8 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 9 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 10 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s 11 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 12 #ifdef CK1 13 14 template <typename T, int X, long long Y> 15 struct SS{ 16 T a[X]; 17 float b; 18 // CK1: define {{.*}}i32 @{{.+}}foo{{.+}}( 19 int foo(void) { 20 21 // CK1: call i32 @__tgt_target( 22 // CK1: call void @[[OFFL1:.+]]( 23 #pragma omp target 24 #pragma omp teams distribute 25 for(int i = 0; i < X; i++) { 26 a[i] = (T)0; 27 } 28 // CK1: call i32 @__tgt_target( 29 // CK1: call void @[[OFFL2:.+]]( 30 #pragma omp target 31 #pragma omp teams distribute dist_schedule(static) 32 for(int i = 0; i < X; i++) { 33 a[i] = (T)0; 34 } 35 // CK1: call i32 @__tgt_target( 36 // CK1: call void @[[OFFL3:.+]]( 37 #pragma omp target 38 #pragma omp teams distribute dist_schedule(static, X/2) 39 for(int i = 0; i < X; i++) { 40 a[i] = (T)0; 41 } 42 // CK1: define internal void @[[OFFL1]]( 43 // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL1:.+]] to {{.+}}, 44 // CK1: ret void 45 46 // CK1: define internal void @[[OUTL1]]({{.+}}) 47 // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 48 // CK1: call void @__kmpc_for_static_fini( 49 // CK1: ret void 50 51 // CK1: define internal void @[[OFFL2]]( 52 // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL2:.+]] to {{.+}}, 53 // CK1: ret void 54 55 // CK1: define internal void @[[OUTL2]]({{.+}}) 56 // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 57 // CK1: call void @__kmpc_for_static_fini( 58 // CK1: ret void 59 60 // CK1: define internal void @[[OFFL3]]( 61 // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL3:.+]] to {{.+}}, 62 // CK1: ret void 63 64 // CK1: define internal void @[[OUTL3]]({{.+}}) 65 // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 66 // CK1: call void @__kmpc_for_static_fini( 67 // CK1: ret void 68 69 return a[0]; 70 } 71 }; 72 73 int teams_template_struct(void) { 74 SS<int, 123, 456> V; 75 return V.foo(); 76 77 } 78 #endif // CK1 79 80 // Test host codegen. 81 // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 82 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s 83 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 84 // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32 85 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s 86 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32 87 #ifdef CK2 88 89 template <typename T, int n> 90 int tmain(T argc) { 91 T a[n]; 92 #pragma omp target 93 #pragma omp teams distribute 94 for(int i = 0; i < n; i++) { 95 a[i] = (T)0; 96 } 97 #pragma omp target 98 #pragma omp teams distribute dist_schedule(static) 99 for(int i = 0; i < n; i++) { 100 a[i] = (T)0; 101 } 102 #pragma omp target 103 #pragma omp teams distribute dist_schedule(static, n) 104 for(int i = 0; i < n; i++) { 105 a[i] = (T)0; 106 } 107 return 0; 108 } 109 110 int main (int argc, char **argv) { 111 int n = 100; 112 int a[n]; 113 #pragma omp target 114 #pragma omp teams distribute 115 for(int i = 0; i < n; i++) { 116 a[i] = 0; 117 } 118 #pragma omp target 119 #pragma omp teams distribute dist_schedule(static) 120 for(int i = 0; i < n; i++) { 121 a[i] = 0; 122 } 123 #pragma omp target 124 #pragma omp teams distribute dist_schedule(static, n) 125 for(int i = 0; i < n; i++) { 126 a[i] = 0; 127 } 128 return tmain<int, 10>(argc); 129 } 130 131 // CK2: define {{.*}}i32 @{{[^,]+}}(i{{.+}}{{.+}} %[[ARGC:.+]], {{.+}}) 132 // CK2: call i32 @__tgt_target( 133 // CK2: call void @[[OFFL1:.+]]({{.+}}) 134 // CK2: call i32 @__tgt_target( 135 // CK2: call void @[[OFFL2:.+]]({{.+}}) 136 // CK2: call i32 @__tgt_target( 137 // CK2: call void @[[OFFL3:.+]]({{.+}}) 138 // CK2: {{%.+}} = call{{.*}} i32 @[[TMAIN:.+]]({{.+}}) 139 // CK2: ret 140 141 // CK2: define {{.*}}void @[[OFFL1]]({{.+}}) 142 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL1:.+]] to {{.+}}, 143 // CK2: ret void 144 145 // CK2: define internal void @[[OUTL1]]({{.+}}) 146 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 147 // CK2: call void @__kmpc_for_static_fini( 148 // CK2: ret void 149 150 // CK2: define {{.*}}void @[[OFFL2]]({{.+}}) 151 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL2:.+]] to {{.+}}, 152 // CK2: ret void 153 154 // CK2: define internal void @[[OUTL2]]({{.+}}) 155 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 156 // CK2: call void @__kmpc_for_static_fini( 157 // CK2: ret void 158 159 // CK2: define {{.*}}void @[[OFFL3]]({{.+}}) 160 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 4, {{.+}} @[[OUTL3:.+]] to {{.+}}, 161 // CK2: ret void 162 163 // CK2: define internal void @[[OUTL3]]({{.+}}) 164 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 165 // CK2: call void @__kmpc_for_static_fini( 166 // CK2: ret void 167 168 // CK2: define {{.*}}i32 @[[TMAIN]]({{.+}}) 169 // CK2: call i32 @__tgt_target( 170 // CK2: call void @[[OFFLT1:.+]]({{.+}}) 171 // CK2: call i32 @__tgt_target( 172 // CK2: call void @[[OFFLT2:.+]]({{.+}}) 173 // CK2: call i32 @__tgt_target( 174 // CK2: call void @[[OFFLT3:.+]]({{.+}}) 175 // CK2: ret 176 // CK2-NEXT: } 177 178 // CK2: define {{.*}}void @[[OFFLT1]]({{.+}}) 179 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT1:.+]] to {{.+}}, 180 // CK2: ret void 181 182 // CK2: define internal void @[[OUTLT1]]({{.+}}) 183 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 184 // CK2: call void @__kmpc_for_static_fini( 185 // CK2: ret void 186 187 // CK2: define {{.*}}void @[[OFFLT2]]({{.+}}) 188 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT2:.+]] to {{.+}}, 189 // CK2: ret void 190 191 // CK2: define internal void @[[OUTLT2]]({{.+}}) 192 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92 193 // CK2: call void @__kmpc_for_static_fini( 194 // CK2: ret void 195 196 // CK2: define {{.*}}void @[[OFFLT3]]({{.+}}) 197 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT3:.+]] to {{.+}}, 198 // CK2: ret void 199 200 // CK2: define internal void @[[OUTLT3]]({{.+}}) 201 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91 202 // CK2: call void @__kmpc_for_static_fini( 203 // CK2: ret void 204 205 #endif // CK2 206 #endif // #ifndef HEADER 207