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 // RUN: %clang_cc1 -fopenmp -x c++ %s -verify -debug-info-kind=limited -emit-llvm -o - -triple x86_64-apple-darwin10 | FileCheck %s --check-prefix=CHECK --check-prefix=DEBUG 5 6 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s 7 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s 8 // 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 9 // RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -debug-info-kind=limited -emit-llvm -o - -triple x86_64-apple-darwin10 | 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 void **omp_allocator_handle_t; 16 extern const omp_allocator_handle_t omp_null_allocator; 17 extern const omp_allocator_handle_t omp_default_mem_alloc; 18 extern const omp_allocator_handle_t omp_large_cap_mem_alloc; 19 extern const omp_allocator_handle_t omp_const_mem_alloc; 20 extern const omp_allocator_handle_t omp_high_bw_mem_alloc; 21 extern const omp_allocator_handle_t omp_low_lat_mem_alloc; 22 extern const omp_allocator_handle_t omp_cgroup_mem_alloc; 23 extern const omp_allocator_handle_t omp_pteam_mem_alloc; 24 extern const omp_allocator_handle_t omp_thread_mem_alloc; 25 26 // CHECK-DAG: @reduction_size.[[ID:.+]]_[[CID:[0-9]+]].artificial. 27 // CHECK-DAG: @reduction_size.[[ID]]_[[CID]].artificial..cache. 28 29 struct S { 30 int a; 31 S() : a(0) {} 32 S(const S&) {} 33 S& operator=(const S&) {return *this;} 34 ~S() {} 35 friend S operator+(const S&a, const S&b) {return a;} 36 }; 37 38 int main(int argc, char **argv) { 39 int a; 40 float b; 41 S c[5]; 42 short d[argc]; 43 #pragma omp taskgroup allocate(omp_pteam_mem_alloc: a) task_reduction(+: a, b, argc) 44 { 45 #pragma omp taskgroup task_reduction(-:c, d) 46 ; 47 } 48 return 0; 49 } 50 // CHECK-LABEL: @main 51 // CHECK: alloca i32, 52 // CHECK: [[ARGC_ADDR:%.+]] = alloca i32, 53 // CHECK: [[ARGV_ADDR:%.+]] = alloca i8**, 54 // CHECK: [[A:%.+]] = alloca i32, 55 // CHECK: [[B:%.+]] = alloca float, 56 // CHECK: [[C:%.+]] = alloca [5 x %struct.S], 57 // CHECK: [[RD_IN1:%.+]] = alloca [3 x [[T1:%[^,]+]]], 58 // CHECK: [[TD1:%.+]] = alloca i8*, 59 // CHECK: [[RD_IN2:%.+]] = alloca [2 x [[T2:%[^,]+]]], 60 // CHECK: [[TD2:%.+]] = alloca i8*, 61 62 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* 63 // CHECK: [[VLA:%.+]] = alloca i16, i64 [[VLA_SIZE:%[^,]+]], 64 65 // CHECK: call void @__kmpc_taskgroup(%struct.ident_t* {{[^,]+}}, i32 [[GTID]]) 66 // CHECK-DAG: [[BC_A:%.+]] = bitcast i32* [[A]] to i8* 67 // CHECK-DAG: store i8* [[BC_A]], i8** [[A_REF:[^,]+]], 68 // CHECK-DAG: [[A_REF]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPA:%[^,]+]], i32 0, i32 0 69 // CHECK-DAG: [[BC_A:%.+]] = bitcast i32* [[A]] to i8* 70 // CHECK-DAG: store i8* [[BC_A]], i8** [[A_REF:[^,]+]], 71 // CHECK-DAG: [[A_REF]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPA]], i32 0, i32 1 72 // CHECK-DAG: [[GEPA]] = getelementptr inbounds [3 x [[T1]]], [3 x [[T1]]]* [[RD_IN1]], i64 0, i64 73 // CHECK-DAG: [[TMP6:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPA]], i32 0, i32 2 74 // CHECK-DAG: store i64 4, i64* [[TMP6]], 75 // CHECK-DAG: [[TMP7:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPA]], i32 0, i32 3 76 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[AINIT:.+]] to i8*), i8** [[TMP7]], 77 // CHECK-DAG: [[TMP8:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPA]], i32 0, i32 4 78 // CHECK-DAG: store i8* null, i8** [[TMP8]], 79 // CHECK-DAG: [[TMP9:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPA]], i32 0, i32 5 80 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[ACOMB:.+]] to i8*), i8** [[TMP9]], 81 // CHECK-DAG: [[TMP10:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPA]], i32 0, i32 6 82 // CHECK-DAG: [[TMP11:%.+]] = bitcast i32* [[TMP10]] to i8* 83 // CHECK-DAG: call void @llvm.memset.p0i8.i64(i8* align 8 [[TMP11]], i8 0, i64 4, i1 false) 84 // CHECK-DAG: [[TMP13:%.+]] = bitcast float* [[B]] to i8* 85 // CHECK-DAG: store i8* [[TMP13]], i8** [[TMP12:%[^,]+]], 86 // CHECK-DAG: [[TMP12]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPB:%[^,]+]], i32 0, i32 0 87 // CHECK-DAG: [[TMP13:%.+]] = bitcast float* [[B]] to i8* 88 // CHECK-DAG: store i8* [[TMP13]], i8** [[TMP12:%[^,]+]], 89 // CHECK-DAG: [[TMP12]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPB]], i32 0, i32 1 90 // CHECK-DAG: [[GEPB]] = getelementptr inbounds [3 x [[T1]]], [3 x [[T1]]]* [[RD_IN1]], i64 0, i64 91 // CHECK-DAG: [[TMP14:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPB]], i32 0, i32 2 92 // CHECK-DAG: store i64 4, i64* [[TMP14]], 93 // CHECK-DAG: [[TMP15:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPB]], i32 0, i32 3 94 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[BINIT:.+]] to i8*), i8** [[TMP15]], 95 // CHECK-DAG: [[TMP16:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPB]], i32 0, i32 4 96 // CHECK-DAG: store i8* null, i8** [[TMP16]], 97 // CHECK-DAG: [[TMP17:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPB]], i32 0, i32 5 98 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[BCOMB:.+]] to i8*), i8** [[TMP17]], 99 // CHECK-DAG: [[TMP18:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPB]], i32 0, i32 6 100 // CHECK-DAG: [[TMP19:%.+]] = bitcast i32* [[TMP18]] to i8* 101 // CHECK-DAG: call void @llvm.memset.p0i8.i64(i8* align 8 [[TMP19]], i8 0, i64 4, i1 false) 102 // CHECK-DAG: [[TMP21:%.+]] = bitcast i32* [[ARGC_ADDR]] to i8* 103 // CHECK-DAG: store i8* [[TMP21]], i8** [[TMP20:%[^,]+]], 104 // CHECK-DAG: [[TMP20]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPARGC:%[^,]+]], i32 0, i32 0 105 // CHECK-DAG: [[TMP21:%.+]] = bitcast i32* [[ARGC_ADDR]] to i8* 106 // CHECK-DAG: store i8* [[TMP21]], i8** [[TMP20:%[^,]+]], 107 // CHECK-DAG: [[TMP20]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPARGC]], i32 0, i32 1 108 // CHECK-DAG: [[GEPARGC]] = getelementptr inbounds [3 x [[T1]]], [3 x [[T1]]]* [[RD_IN1]], i64 0, i64 109 // CHECK-DAG: [[TMP22:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPARGC]], i32 0, i32 2 110 // CHECK-DAG: store i64 4, i64* [[TMP22]], 111 // CHECK-DAG: [[TMP23:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPARGC]], i32 0, i32 3 112 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[ARGCINIT:.+]] to i8*), i8** [[TMP23]], 113 // CHECK-DAG: [[TMP24:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPARGC]], i32 0, i32 4 114 // CHECK-DAG: store i8* null, i8** [[TMP24]], 115 // CHECK-DAG: [[TMP25:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPARGC]], i32 0, i32 5 116 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[ARGCCOMB:.+]] to i8*), i8** [[TMP25]], 117 // CHECK-DAG: [[TMP26:%.+]] = getelementptr inbounds [[T1]], [[T1]]* [[GEPARGC]], i32 0, i32 6 118 // CHECK-DAG: [[TMP27:%.+]] = bitcast i32* [[TMP26]] to i8* 119 // CHECK-DAG: call void @llvm.memset.p0i8.i64(i8* align 8 [[TMP27]], i8 0, i64 4, i1 false) 120 // CHECK-DAG: [[TMP28:%.+]] = bitcast [3 x [[T1]]]* [[RD_IN1]] to i8* 121 // CHECK-DAG: [[TMP29:%.+]] = call i8* @__kmpc_taskred_init(i32 [[GTID]], i32 3, i8* [[TMP28]]) 122 // DEBUG-DAG: call void @llvm.dbg.declare(metadata i8** [[TD1]], 123 // CHECK-DAG: store i8* [[TMP29]], i8** [[TD1]], 124 // CHECK-DAG: call void @__kmpc_taskgroup(%struct.ident_t* {{[^,]+}}, i32 [[GTID]]) 125 // CHECK-DAG: [[TMP31:%.+]] = bitcast [5 x %struct.S]* [[C]] to i8* 126 // CHECK-DAG: store i8* [[TMP31]], i8** [[TMP30:%[^,]+]], 127 // CHECK-DAG: [[TMP30]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPC:%[^,]+]], i32 0, i32 0 128 // CHECK-DAG: [[TMP31:%.+]] = bitcast [5 x %struct.S]* [[C]] to i8* 129 // CHECK-DAG: store i8* [[TMP31]], i8** [[TMP30:%[^,]+]], 130 // CHECK-DAG: [[TMP30]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPC]], i32 0, i32 1 131 // CHECK-DAG: [[GEPC]] = getelementptr inbounds [2 x [[T2]]], [2 x [[T2]]]* [[RD_IN2]], i64 0, i64 132 // CHECK-DAG: [[TMP32:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPC]], i32 0, i32 2 133 // CHECK-DAG: store i64 20, i64* [[TMP32]], 134 // CHECK-DAG: [[TMP33:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPC]], i32 0, i32 3 135 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[CINIT:.+]] to i8*), i8** [[TMP33]], 136 // CHECK-DAG: [[TMP34:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPC]], i32 0, i32 4 137 // CHECK-DAG: store i8* bitcast (void (i8*)* @[[CFINI:.+]] to i8*), i8** [[TMP34]], 138 // CHECK-DAG: [[TMP35:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPC]], i32 0, i32 5 139 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[CCOMB:.+]] to i8*), i8** [[TMP35]], 140 // CHECK-DAG: [[TMP36:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPC]], i32 0, i32 6 141 // CHECK-DAG: [[TMP37:%.+]] = bitcast i32* [[TMP36]] to i8* 142 // CHECK-DAG: call void @llvm.memset.p0i8.i64(i8* align 8 [[TMP37]], i8 0, i64 4, i1 false) 143 // CHECK-DAG: [[TMP39:%.+]] = bitcast i16* [[VLA]] to i8* 144 // CHECK-DAG: store i8* [[TMP39]], i8** [[TMP38:%[^,]+]], 145 // CHECK-DAG: [[TMP38]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPVLA:%[^,]+]], i32 0, i32 0 146 // CHECK-DAG: [[TMP39:%.+]] = bitcast i16* [[VLA]] to i8* 147 // CHECK-DAG: store i8* [[TMP39]], i8** [[TMP38:%[^,]+]], 148 // CHECK-DAG: [[TMP38]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPVLA]], i32 0, i32 1 149 // CHECK-DAG: [[GEPVLA]] = getelementptr inbounds [2 x [[T2]]], [2 x [[T2]]]* [[RD_IN2]], i64 0, i64 150 // CHECK-DAG: [[TMP40:%.+]] = mul nuw i64 [[VLA_SIZE]], 2 151 // CHECK-DAG: [[TMP41:%.+]] = udiv exact i64 [[TMP40]], ptrtoint (i16* getelementptr (i16, i16* null, i32 1) to i64) 152 // CHECK-DAG: [[TMP42:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPVLA]], i32 0, i32 2 153 // CHECK-DAG: store i64 [[TMP40]], i64* [[TMP42]], 154 // CHECK-DAG: [[TMP43:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPVLA]], i32 0, i32 3 155 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[VLAINIT:.+]] to i8*), i8** [[TMP43]], 156 // CHECK-DAG: [[TMP44:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPVLA]], i32 0, i32 4 157 // CHECK-DAG: store i8* null, i8** [[TMP44]], 158 // CHECK-DAG: [[TMP45:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPVLA]], i32 0, i32 5 159 // CHECK-DAG: store i8* bitcast (void (i8*, i8*)* @[[VLACOMB:.+]] to i8*), i8** [[TMP45]], 160 // CHECK-DAG: [[TMP46:%.+]] = getelementptr inbounds [[T2]], [[T2]]* [[GEPVLA]], i32 0, i32 6 161 // CHECK-DAG: store i32 1, i32* [[TMP46]], 162 // CHECK: [[TMP47:%.+]] = bitcast [2 x [[T2]]]* [[RD_IN2]] to i8* 163 // CHECK: [[TMP48:%.+]] = call i8* @__kmpc_taskred_init(i32 [[GTID]], i32 2, i8* [[TMP47]]) 164 // CHECK: store i8* [[TMP48]], i8** [[TD2]], 165 // CHECK: call void @__kmpc_end_taskgroup(%struct.ident_t* {{[^,]+}}, i32 [[GTID]]) 166 // CHECK: call void @__kmpc_end_taskgroup(%struct.ident_t* {{[^,]+}}, i32 [[GTID]]) 167 168 // CHECK-DAG: define internal void @[[AINIT]](i8* noalias noundef %{{.+}}, i8* noalias noundef %{{.+}}) 169 // CHECK-DAG: store i32 0, i32* % 170 // CHECK-DAG: ret void 171 // CHECK-DAG: } 172 173 // CHECK-DAG: define internal void @[[ACOMB]](i8* noundef %0, i8* noundef %1) 174 // CHECK-DAG: add nsw i32 % 175 // CHECK-DAG: store i32 % 176 // CHECK-DAG: ret void 177 // CHECK-DAG: } 178 179 // CHECK-DAG: define internal void @[[BINIT]](i8* noalias noundef %{{.+}}, i8* noalias noundef %{{.+}}) 180 // CHECK-DAG: store float 0.000000e+00, float* % 181 // CHECK-DAG: ret void 182 // CHECK-DAG: } 183 184 // CHECK-DAG: define internal void @[[BCOMB]](i8* noundef %0, i8* noundef %1) 185 // CHECK-DAG: fadd float % 186 // CHECK-DAG: store float % 187 // CHECK-DAG: ret void 188 // CHECK-DAG: } 189 190 // CHECK-DAG: define internal void @[[ARGCINIT]](i8* noalias noundef %{{.+}}, i8* noalias noundef %{{.+}}) 191 // CHECK-DAG: store i32 0, i32* % 192 // CHECK-DAG: ret void 193 // CHECK-DAG: } 194 195 // CHECK-DAG: define internal void @[[ARGCCOMB]](i8* noundef %0, i8* noundef %1) 196 // CHECK-DAG: add nsw i32 % 197 // CHECK-DAG: store i32 % 198 // CHECK-DAG: ret void 199 // CHECK-DAG: } 200 201 // CHECK-DAG: define internal void @[[CINIT]](i8* noalias noundef %{{.+}}, i8* noalias noundef %{{.+}}) 202 // CHECK-DAG: phi %struct.S* [ 203 // CHECK-DAG: call {{.+}}(%struct.S* {{.+}}) 204 // CHECK-DAG: br i1 % 205 // CHECK-DAG: ret void 206 // CHECK-DAG: } 207 208 // CHECK-DAG: define internal void @[[CFINI]](i8* noundef %0) 209 // CHECK-DAG: phi %struct.S* [ 210 // CHECK-DAG: call {{.+}}(%struct.S* {{.+}}) 211 // CHECK-DAG: br i1 % 212 // CHECK-DAG: ret void 213 // CHECK-DAG: } 214 215 // CHECK-DAG: define internal void @[[CCOMB]](i8* noundef %0, i8* noundef %1) 216 // CHECK-DAG: phi %struct.S* [ 217 // CHECK-DAG: phi %struct.S* [ 218 // CHECK-DAG: call {{.+}}(%struct.S* {{.+}}, %struct.S* {{.+}}, %struct.S* {{.+}}) 219 // CHECK-DAG: call {{.+}}(%struct.S* {{.+}}, %struct.S* {{.+}}) 220 // CHECK-DAG: call {{.+}}(%struct.S* {{.+}}) 221 // CHECK-DAG: br i1 % 222 // CHECK-DAG: ret void 223 // CHECK_DAG: } 224 225 // CHECK-DAG: define internal void @[[VLAINIT]](i8* noalias noundef %{{.+}}, i8* noalias noundef %{{.+}}) 226 // CHECK-DAG: call i32 @__kmpc_global_thread_num(%struct.ident_t* {{[^,]+}}) 227 // CHECK-DAG: call i8* @__kmpc_threadprivate_cached(%struct.ident_t* 228 // CHECK-DAG: phi i16* [ 229 // CHECK-DAG: store i16 0, i16* % 230 // CHECK-DAG: br i1 % 231 // CHECK-DAG: ret void 232 // CHECK-DAG: } 233 234 // CHECK-DAG: define internal void @[[VLACOMB]](i8* noundef %0, i8* noundef %1) 235 // CHECK-DAG: call i32 @__kmpc_global_thread_num(%struct.ident_t* {{[^,]+}}) 236 // CHECK-DAG: call i8* @__kmpc_threadprivate_cached(%struct.ident_t* 237 // CHECK-DAG: phi i16* [ 238 // CHECK-DAG: phi i16* [ 239 // CHECK-DAG: sext i16 %{{.+}} to i32 240 // CHECK-DAG: add nsw i32 % 241 // CHECK-DAG: trunc i32 %{{.+}} to i16 242 // CHECK-DAG: store i16 % 243 // CHECK_DAG: br i1 % 244 // CHECK-DAG: ret void 245 // CHECK-DAG: } 246 #endif 247 248 // DEBUG-LABEL: distinct !DICompileUnit 249 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[AINIT]]", 250 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ACOMB]]", 251 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[BINIT]]", 252 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[BCOMB]]", 253 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ARGCINIT]]", 254 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ARGCCOMB]]", 255 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CINIT]]", 256 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CFINI]]", 257 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CCOMB]]", 258 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[VLAINIT]]", 259 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[VLACOMB]]", 260