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