244 lines · cpp
1// RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s2// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s3// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s4// RUN: %clang_cc1 -fopenmp -x c++ %s -verify -Wno-vla -debug-info-kind=limited -emit-llvm -o - -triple x86_64-apple-darwin10 | FileCheck %s --check-prefix=CHECK --check-prefix=DEBUG5 6// RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s7// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s8// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s9// RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -Wno-vla -debug-info-kind=limited -emit-llvm -o - -triple x86_64-apple-darwin10 | FileCheck --check-prefix SIMD-ONLY0 %s10// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}11// expected-no-diagnostics12#ifndef HEADER13#define HEADER14 15typedef void **omp_allocator_handle_t;16extern const omp_allocator_handle_t omp_null_allocator;17extern const omp_allocator_handle_t omp_default_mem_alloc;18extern const omp_allocator_handle_t omp_large_cap_mem_alloc;19extern const omp_allocator_handle_t omp_const_mem_alloc;20extern const omp_allocator_handle_t omp_high_bw_mem_alloc;21extern const omp_allocator_handle_t omp_low_lat_mem_alloc;22extern const omp_allocator_handle_t omp_cgroup_mem_alloc;23extern const omp_allocator_handle_t omp_pteam_mem_alloc;24extern 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 29struct 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 38int 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: @main51// CHECK: alloca i32,52// CHECK: [[ARGC_ADDR:%.+]] = alloca i32,53// CHECK: [[ARGV_ADDR:%.+]] = alloca ptr,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 ptr,59// CHECK: [[RD_IN2:%.+]] = alloca [2 x [[T2:%[^,]+]]],60// CHECK: [[TD2:%.+]] = alloca ptr,61 62// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(ptr63// CHECK: [[VLA:%.+]] = alloca i16, i64 [[VLA_SIZE:%[^,]+]],64 65// CHECK: call void @__kmpc_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])66// CHECK-DAG: store ptr [[A]], ptr [[A_REF:[^,]+]],67// CHECK-DAG: [[A_REF]] = getelementptr inbounds nuw [[T1]], ptr [[GEPA:%[^,]+]], i32 0, i32 068// CHECK-DAG: store ptr [[A]], ptr [[A_REF:[^,]+]],69// CHECK-DAG: [[A_REF]] = getelementptr inbounds nuw [[T1]], ptr [[GEPA]], i32 0, i32 170// CHECK-DAG: [[GEPA]] = getelementptr inbounds nuw [3 x [[T1]]], ptr [[RD_IN1]], i64 0, i6471// CHECK-DAG: [[TMP6:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPA]], i32 0, i32 272// CHECK-DAG: store i64 4, ptr [[TMP6]],73// CHECK-DAG: [[TMP7:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPA]], i32 0, i32 374// CHECK-DAG: store ptr @[[AINIT:.+]], ptr [[TMP7]],75// CHECK-DAG: [[TMP8:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPA]], i32 0, i32 476// CHECK-DAG: store ptr null, ptr [[TMP8]],77// CHECK-DAG: [[TMP9:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPA]], i32 0, i32 578// CHECK-DAG: store ptr @[[ACOMB:.+]], ptr [[TMP9]],79// CHECK-DAG: [[TMP10:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPA]], i32 0, i32 680// CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP10]], i8 0, i64 4, i1 false)81// CHECK-DAG: store ptr [[B]], ptr [[TMP12:%[^,]+]],82// CHECK-DAG: [[TMP12]] = getelementptr inbounds nuw [[T1]], ptr [[GEPB:%[^,]+]], i32 0, i32 083// CHECK-DAG: store ptr [[B]], ptr [[TMP12:%[^,]+]],84// CHECK-DAG: [[TMP12]] = getelementptr inbounds nuw [[T1]], ptr [[GEPB]], i32 0, i32 185// CHECK-DAG: [[GEPB]] = getelementptr inbounds nuw [3 x [[T1]]], ptr [[RD_IN1]], i64 0, i6486// CHECK-DAG: [[TMP14:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPB]], i32 0, i32 287// CHECK-DAG: store i64 4, ptr [[TMP14]],88// CHECK-DAG: [[TMP15:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPB]], i32 0, i32 389// CHECK-DAG: store ptr @[[BINIT:.+]], ptr [[TMP15]],90// CHECK-DAG: [[TMP16:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPB]], i32 0, i32 491// CHECK-DAG: store ptr null, ptr [[TMP16]],92// CHECK-DAG: [[TMP17:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPB]], i32 0, i32 593// CHECK-DAG: store ptr @[[BCOMB:.+]], ptr [[TMP17]],94// CHECK-DAG: [[TMP18:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPB]], i32 0, i32 695// CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP18]], i8 0, i64 4, i1 false)96// CHECK-DAG: store ptr [[ARGC_ADDR]], ptr [[TMP20:%[^,]+]],97// CHECK-DAG: [[TMP20]] = getelementptr inbounds nuw [[T1]], ptr [[GEPARGC:%[^,]+]], i32 0, i32 098// CHECK-DAG: store ptr [[ARGC_ADDR]], ptr [[TMP20:%[^,]+]],99// CHECK-DAG: [[TMP20]] = getelementptr inbounds nuw [[T1]], ptr [[GEPARGC]], i32 0, i32 1100// CHECK-DAG: [[GEPARGC]] = getelementptr inbounds nuw [3 x [[T1]]], ptr [[RD_IN1]], i64 0, i64101// CHECK-DAG: [[TMP22:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPARGC]], i32 0, i32 2102// CHECK-DAG: store i64 4, ptr [[TMP22]],103// CHECK-DAG: [[TMP23:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPARGC]], i32 0, i32 3104// CHECK-DAG: store ptr @[[ARGCINIT:.+]], ptr [[TMP23]],105// CHECK-DAG: [[TMP24:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPARGC]], i32 0, i32 4106// CHECK-DAG: store ptr null, ptr [[TMP24]],107// CHECK-DAG: [[TMP25:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPARGC]], i32 0, i32 5108// CHECK-DAG: store ptr @[[ARGCCOMB:.+]], ptr [[TMP25]],109// CHECK-DAG: [[TMP26:%.+]] = getelementptr inbounds nuw [[T1]], ptr [[GEPARGC]], i32 0, i32 6110// CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP26]], i8 0, i64 4, i1 false)111// CHECK-DAG: [[TMP29:%.+]] = call ptr @__kmpc_taskred_init(i32 [[GTID]], i32 3, ptr [[RD_IN1]])112// DEBUG-DAG: #dbg_declare(ptr [[TD1]],113// CHECK-DAG: store ptr [[TMP29]], ptr [[TD1]],114// CHECK-DAG: call void @__kmpc_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])115// CHECK-DAG: store ptr [[C]], ptr [[TMP30:%[^,]+]],116// CHECK-DAG: [[TMP30]] = getelementptr inbounds nuw [[T2]], ptr [[GEPC:%[^,]+]], i32 0, i32 0117// CHECK-DAG: store ptr [[C]], ptr [[TMP30:%[^,]+]],118// CHECK-DAG: [[TMP30]] = getelementptr inbounds nuw [[T2]], ptr [[GEPC]], i32 0, i32 1119// CHECK-DAG: [[GEPC]] = getelementptr inbounds nuw [2 x [[T2]]], ptr [[RD_IN2]], i64 0, i64120// CHECK-DAG: [[TMP32:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPC]], i32 0, i32 2121// CHECK-DAG: store i64 20, ptr [[TMP32]],122// CHECK-DAG: [[TMP33:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPC]], i32 0, i32 3123// CHECK-DAG: store ptr @[[CINIT:.+]], ptr [[TMP33]],124// CHECK-DAG: [[TMP34:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPC]], i32 0, i32 4125// CHECK-DAG: store ptr @[[CFINI:.+]], ptr [[TMP34]],126// CHECK-DAG: [[TMP35:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPC]], i32 0, i32 5127// CHECK-DAG: store ptr @[[CCOMB:.+]], ptr [[TMP35]],128// CHECK-DAG: [[TMP36:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPC]], i32 0, i32 6129// CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP36]], i8 0, i64 4, i1 false)130// CHECK-DAG: store ptr [[VLA]], ptr [[TMP38:%[^,]+]],131// CHECK-DAG: [[TMP38]] = getelementptr inbounds nuw [[T2]], ptr [[GEPVLA:%[^,]+]], i32 0, i32 0132// CHECK-DAG: store ptr [[VLA]], ptr [[TMP38:%[^,]+]],133// CHECK-DAG: [[TMP38]] = getelementptr inbounds nuw [[T2]], ptr [[GEPVLA]], i32 0, i32 1134// CHECK-DAG: [[GEPVLA]] = getelementptr inbounds nuw [2 x [[T2]]], ptr [[RD_IN2]], i64 0, i64135// CHECK-DAG: [[TMP40:%.+]] = mul nuw i64 [[VLA_SIZE]], 2136// CHECK-DAG: [[TMP41:%.+]] = udiv exact i64 [[TMP40]], ptrtoint (ptr getelementptr (i16, ptr null, i32 1) to i64)137// CHECK-DAG: [[TMP42:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPVLA]], i32 0, i32 2138// CHECK-DAG: store i64 [[TMP40]], ptr [[TMP42]],139// CHECK-DAG: [[TMP43:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPVLA]], i32 0, i32 3140// CHECK-DAG: store ptr @[[VLAINIT:.+]], ptr [[TMP43]],141// CHECK-DAG: [[TMP44:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPVLA]], i32 0, i32 4142// CHECK-DAG: store ptr null, ptr [[TMP44]],143// CHECK-DAG: [[TMP45:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPVLA]], i32 0, i32 5144// CHECK-DAG: store ptr @[[VLACOMB:.+]], ptr [[TMP45]],145// CHECK-DAG: [[TMP46:%.+]] = getelementptr inbounds nuw [[T2]], ptr [[GEPVLA]], i32 0, i32 6146// CHECK-DAG: store i32 1, ptr [[TMP46]],147// CHECK: [[TMP48:%.+]] = call ptr @__kmpc_taskred_init(i32 [[GTID]], i32 2, ptr [[RD_IN2]])148// CHECK: store ptr [[TMP48]], ptr [[TD2]],149// CHECK: call void @__kmpc_end_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])150// CHECK: call void @__kmpc_end_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])151 152// CHECK-DAG: define internal void @[[AINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})153// CHECK-DAG: store i32 0, ptr %154// CHECK-DAG: ret void155// CHECK-DAG: }156 157// CHECK-DAG: define internal void @[[ACOMB]](ptr noundef %0, ptr noundef %1)158// CHECK-DAG: add nsw i32 %159// CHECK-DAG: store i32 %160// CHECK-DAG: ret void161// CHECK-DAG: }162 163// CHECK-DAG: define internal void @[[BINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})164// CHECK-DAG: store float 0.000000e+00, ptr %165// CHECK-DAG: ret void166// CHECK-DAG: }167 168// CHECK-DAG: define internal void @[[BCOMB]](ptr noundef %0, ptr noundef %1)169// CHECK-DAG: fadd float %170// CHECK-DAG: store float %171// CHECK-DAG: ret void172// CHECK-DAG: }173 174// CHECK-DAG: define internal void @[[ARGCINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})175// CHECK-DAG: store i32 0, ptr %176// CHECK-DAG: ret void177// CHECK-DAG: }178 179// CHECK-DAG: define internal void @[[ARGCCOMB]](ptr noundef %0, ptr noundef %1)180// CHECK-DAG: add nsw i32 %181// CHECK-DAG: store i32 %182// CHECK-DAG: ret void183// CHECK-DAG: }184 185// CHECK-DAG: define internal void @[[CINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})186// CHECK-DAG: phi ptr [187// CHECK-DAG: call {{.+}}(ptr {{.+}})188// CHECK-DAG: br i1 %189// CHECK-DAG: ret void190// CHECK-DAG: }191 192// CHECK-DAG: define internal void @[[CFINI]](ptr noundef %0)193// CHECK-DAG: phi ptr [194// CHECK-DAG: call {{.+}}(ptr {{.+}})195// CHECK-DAG: br i1 %196// CHECK-DAG: ret void197// CHECK-DAG: }198 199// CHECK-DAG: define internal void @[[CCOMB]](ptr noundef %0, ptr noundef %1)200// CHECK-DAG: phi ptr [201// CHECK-DAG: phi ptr [202// CHECK-DAG: call {{.+}}(ptr {{.+}}, ptr {{.+}}, ptr {{.+}})203// CHECK-DAG: call {{.+}}(ptr {{.+}}, ptr {{.+}})204// CHECK-DAG: call {{.+}}(ptr {{.+}})205// CHECK-DAG: br i1 %206// CHECK-DAG: ret void207// CHECK-DAG: }208 209// CHECK-DAG: define internal void @[[VLAINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})210// CHECK-DAG: call i32 @__kmpc_global_thread_num(ptr {{[^,]+}})211// CHECK-DAG: call ptr @__kmpc_threadprivate_cached(ptr212// CHECK-DAG: phi ptr [213// CHECK-DAG: store i16 0, ptr %214// CHECK-DAG: br i1 %215// CHECK-DAG: ret void216// CHECK-DAG: }217 218// CHECK-DAG: define internal void @[[VLACOMB]](ptr noundef %0, ptr noundef %1)219// CHECK-DAG: call i32 @__kmpc_global_thread_num(ptr {{[^,]+}})220// CHECK-DAG: call ptr @__kmpc_threadprivate_cached(ptr221// CHECK-DAG: phi ptr [222// CHECK-DAG: phi ptr [223// CHECK-DAG: sext i16 %{{.+}} to i32224// CHECK-DAG: add nsw i32 %225// CHECK-DAG: trunc i32 %{{.+}} to i16226// CHECK-DAG: store i16 %227// CHECK-DAG: br i1 %228// CHECK-DAG: ret void229// CHECK-DAG: }230#endif231 232// DEBUG-LABEL: distinct !DICompileUnit233// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[AINIT]]",234// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ACOMB]]",235// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[BINIT]]",236// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[BCOMB]]",237// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ARGCINIT]]",238// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ARGCCOMB]]",239// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CINIT]]",240// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CFINI]]",241// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CCOMB]]",242// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[VLAINIT]]",243// DEBUG-DAG: distinct !DISubprogram(linkageName: "[[VLACOMB]]",244