brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.8 KiB · 6eca033 Raw
226 lines · cpp
1// RUN: %clang_cc1 -fopenmp -x c++ %s -verify -Wno-vla -debug-info-kind=limited -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 | FileCheck %s2 3// RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -Wno-vla -debug-info-kind=limited -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 | FileCheck --check-prefix SIMD-ONLY0 %s4// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}5// expected-no-diagnostics6 7// CHECK: [[RED_SIZE1:@reduction_size[.].+]] = common thread_local global i64 08// CHECK: [[RED_SIZE2:@reduction_size[.].+]] = common thread_local global i64 09 10struct S {11  float a;12  S() : a(0.0f) {}13  ~S() {}14};15 16#pragma omp declare reduction(+:S:omp_out.a += omp_in.a) initializer(omp_priv = omp_orig)17 18float g;19 20int a;21#pragma omp threadprivate(a)22int main (int argc, char *argv[])23{24int   i, n;25float a[100], b[100], sum, e[argc + 100];26S c[100];27float &d = g;28 29/* Some initializations */30n = 100;31for (i=0; i < n; i++)32  a[i] = b[i] = i * 1.0;33sum = 0.0;34 35#pragma omp taskloop reduction(+:sum, c[:n], d, e)36  for (i=0; i < n; i++) {37    sum = sum + (a[i] * b[i]);38    c[i].a = i*i;39    d += i*i;40    e[i] = i;41  }42 43}44 45// CHECK-LABEL: @main(46// CHECK:    [[RETVAL:%.*]] = alloca i32,47// CHECK:    [[ARGC_ADDR:%.*]] = alloca i32,48// CHECK:    [[ARGV_ADDR:%.*]] = alloca ptr,49// CHECK:    [[I:%.*]] = alloca i32,50// CHECK:    [[N:%.*]] = alloca i32,51// CHECK:    [[A:%.*]] = alloca [100 x float],52// CHECK:    [[B:%.*]] = alloca [100 x float],53// CHECK:    [[SUM:%.*]] = alloca float,54// CHECK:    [[SAVED_STACK:%.*]] = alloca ptr,55// CHECK:    [[C:%.*]] = alloca [100 x %struct.S],56// CHECK:    [[D:%.*]] = alloca ptr,57// CHECK:    [[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]],58// CHECK:    [[DOTRD_INPUT_:%.*]] = alloca [4 x %struct.kmp_taskred_input_t],59// CHECK:    alloca i32,60// CHECK:    [[DOTCAPTURE_EXPR_:%.*]] = alloca i32,61// CHECK:    [[DOTCAPTURE_EXPR_9:%.*]] = alloca i32,62// CHECK:    [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr63// CHECK:    store i32 0, ptr [[RETVAL]],64// CHECK:    store i32 [[ARGC:%.*]], ptr [[ARGC_ADDR]],65// CHECK:    store ptr [[ARGV:%.*]], ptr [[ARGV_ADDR]],66// CHECK:    [[TMP1:%.*]] = load i32, ptr [[ARGC_ADDR]],67// CHECK:    [[ADD:%.*]] = add nsw i32 [[TMP1]], 10068// CHECK:    [[TMP2:%.*]] = zext i32 [[ADD]] to i6469// CHECK:    [[VLA:%.+]] = alloca float, i64 %70 71// CHECK:    call void @__kmpc_taskgroup(ptr72// CHECK-DAG:    store ptr [[SUM]], ptr [[TMP20:%[^,]+]],73// CHECK-DAG:    [[TMP20]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_:%.+]], i32 0, i32 074// CHECK-DAG:    store ptr [[SUM]], ptr [[TMP20:%[^,]+]],75// CHECK-DAG:    [[TMP20]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_]], i32 0, i32 176// CHECK-DAG:    [[TMP22:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_]], i32 0, i32 277// CHECK-DAG:    store i64 4, ptr [[TMP22]],78// CHECK-DAG:    [[TMP23:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_]], i32 0, i32 379// CHECK-DAG:    store ptr @[[RED_INIT1:.+]], ptr [[TMP23]],80// CHECK-DAG:    [[TMP24:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_]], i32 0, i32 481// CHECK-DAG:    store ptr null, ptr [[TMP24]],82// CHECK-DAG:    [[TMP25:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_]], i32 0, i32 583// CHECK-DAG:    store ptr @[[RED_COMB1:.+]], ptr [[TMP25]],84// CHECK-DAG:    [[TMP26:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_]], i32 0, i32 685// CHECK-DAG:    call void @llvm.memset.p0.i64(ptr align 8 [[TMP26]], i8 0, i64 4, i1 false)86// CHECK-DAG:    [[ARRAYIDX5:%.*]] = getelementptr inbounds nuw [100 x %struct.S], ptr [[C]], i64 0, i64 087// CHECK-DAG:    [[LB_ADD_LEN:%.*]] = add nsw i64 -1, %88// CHECK-DAG:    [[ARRAYIDX6:%.*]] = getelementptr inbounds nuw [100 x %struct.S], ptr [[C]], i64 0, i64 [[LB_ADD_LEN]]89// CHECK-DAG:    store ptr [[ARRAYIDX5]], ptr [[TMP28:%[^,]+]],90// CHECK-DAG:    [[TMP28]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_4:%.+]], i32 0, i32 091// CHECK-DAG:    store ptr [[ARRAYIDX5]], ptr [[TMP28:%[^,]+]],92// CHECK-DAG:    [[TMP28]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_4]], i32 0, i32 193// CHECK-DAG:    [[TMP32:%.*]] = ptrtoint ptr [[ARRAYIDX6]] to i6494// CHECK-DAG:    [[TMP33:%.*]] = ptrtoint ptr [[ARRAYIDX5]] to i6495// CHECK-DAG:    [[TMP34:%.*]] = sub i64 [[TMP32]], [[TMP33]]96// CHECK-DAG:    [[TMP35:%.*]] = sdiv exact i64 [[TMP34]], ptrtoint (ptr getelementptr (%struct.S, ptr null, i32 1) to i64)97// CHECK-DAG:    [[TMP36:%.*]] = add nuw i64 [[TMP35]], 198// CHECK-DAG:    [[TMP37:%.*]] = mul nuw i64 [[TMP36]], ptrtoint (ptr getelementptr (%struct.S, ptr null, i32 1) to i64)99// CHECK-DAG:    store i64 [[TMP37]], ptr [[TMP38:%[^,]+]],100// CHECK-DAG:    [[TMP38]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_4]], i32 0, i32 2101// CHECK-DAG:    [[TMP39:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_4]], i32 0, i32 3102// CHECK-DAG:    store ptr @[[RED_INIT2:.+]], ptr [[TMP39]],103// CHECK-DAG:    [[TMP40:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_4]], i32 0, i32 4104// CHECK-DAG:    store ptr @[[RED_FINI2:.+]], ptr [[TMP40]],105// CHECK-DAG:    [[TMP41:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_4]], i32 0, i32 5106// CHECK-DAG:    store ptr @[[RED_COMB2:.+]], ptr [[TMP41]],107// CHECK-DAG:    [[TMP42:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_4]], i32 0, i32 6108// CHECK-DAG:    store i32 1, ptr [[TMP42]],109// CHECK-DAG:    [[TMP44:%.*]] = load ptr, ptr [[D]],110// CHECK-DAG:    store ptr [[TMP44]], ptr [[TMP43:%[^,]+]],111// CHECK-DAG:    [[TMP43]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_7:%.+]], i32 0, i32 0112// CHECK-DAG:    store ptr [[TMP44]], ptr [[TMP43:%[^,]+]],113// CHECK-DAG:    [[TMP43]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_7]], i32 0, i32 1114// CHECK-DAG:    [[TMP46:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_7]], i32 0, i32 2115// CHECK-DAG:    store i64 4, ptr [[TMP46]],116// CHECK-DAG:    [[TMP47:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_7]], i32 0, i32 3117// CHECK-DAG:    store ptr @[[RED_INIT3:.+]], ptr [[TMP47]],118// CHECK-DAG:    [[TMP48:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_7]], i32 0, i32 4119// CHECK-DAG:    store ptr null, ptr [[TMP48]],120// CHECK-DAG:    [[TMP49:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_7]], i32 0, i32 5121// CHECK-DAG:    store ptr @[[RED_COMB3:.+]], ptr [[TMP49]],122// CHECK-DAG:    [[TMP50:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_7]], i32 0, i32 6123// CHECK-DAG:    call void @llvm.memset.p0.i64(ptr align 8 [[TMP50]], i8 0, i64 4, i1 false)124// CHECK-DAG:    store ptr [[VLA]], ptr [[TMP52:%[^,]+]],125// CHECK-DAG:    [[TMP52]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_8:%.+]], i32 0, i32 0126// CHECK-DAG:    store ptr [[VLA]], ptr [[TMP52:%[^,]+]],127// CHECK-DAG:    [[TMP52]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_8]], i32 0, i32 1128// CHECK-DAG:    [[TMP54:%.*]] = mul nuw i64 [[TMP2]], 4129// CHECK-DAG:    [[TMP55:%.*]] = udiv exact i64 [[TMP54]], ptrtoint (ptr getelementptr (float, ptr null, i32 1) to i64)130// CHECK-DAG:    store i64 [[TMP54]], ptr [[TMP56:%[^,]+]],131// CHECK-DAG:    [[TMP56]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_8]], i32 0, i32 2132// CHECK-DAG:    [[TMP57:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_8]], i32 0, i32 3133// CHECK-DAG:    store ptr @[[RED_INIT4:.+]], ptr [[TMP57]],134// CHECK-DAG:    [[TMP58:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_8]], i32 0, i32 4135// CHECK-DAG:    store ptr null, ptr [[TMP58]],136// CHECK-DAG:    [[TMP59:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_8]], i32 0, i32 5137// CHECK-DAG:    store ptr @[[RED_COMB4:.+]], ptr [[TMP59]],138// CHECK-DAG:    [[TMP60:%.*]] = getelementptr inbounds nuw %struct.kmp_taskred_input_t, ptr [[DOTRD_INPUT_GEP_8]], i32 0, i32 6139// CHECK-DAG:    store i32 1, ptr [[TMP60]],140// CHECK-DAG:    [[DOTRD_INPUT_GEP_]] = getelementptr inbounds nuw [4 x %struct.kmp_taskred_input_t], ptr [[DOTRD_INPUT_]], i64 0, i64141// CHECK-DAG:    [[DOTRD_INPUT_GEP_4]] = getelementptr inbounds nuw [4 x %struct.kmp_taskred_input_t], ptr [[DOTRD_INPUT_]], i64 0, i64142// CHECK-DAG:    [[DOTRD_INPUT_GEP_7]] = getelementptr inbounds nuw [4 x %struct.kmp_taskred_input_t], ptr [[DOTRD_INPUT_]], i64 0, i64143// CHECK-DAG:    [[DOTRD_INPUT_GEP_8]] = getelementptr inbounds nuw [4 x %struct.kmp_taskred_input_t], ptr [[DOTRD_INPUT_]], i64 0, i64144// CHECK:    [[TMP62:%.*]] = call ptr @__kmpc_taskred_init(i32 [[TMP0]], i32 4, ptr [[DOTRD_INPUT_]])145// CHECK:    [[TMP63:%.*]] = load i32, ptr [[N]],146// CHECK:    store i32 [[TMP63]], ptr [[DOTCAPTURE_EXPR_]],147// CHECK:    [[TMP64:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]],148// CHECK:    [[SUB:%.*]] = sub nsw i32 [[TMP64]], 0149// CHECK:    [[DIV:%.*]] = sdiv i32 [[SUB]], 1150// CHECK:    [[SUB12:%.*]] = sub nsw i32 [[DIV]], 1151// CHECK:    store i32 [[SUB12]], ptr [[DOTCAPTURE_EXPR_9]],152// CHECK:    [[TMP65:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr {{.+}}, i32 [[TMP0]], i32 1, i64 888, i64 40, ptr @[[TASK:.+]])153// CHECK:    call void @__kmpc_taskloop(ptr {{.+}}, i32 [[TMP0]], ptr [[TMP65]], i32 1, ptr %{{.+}}, ptr %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, ptr null)154// CHECK:    call void @__kmpc_end_taskgroup(ptr155 156// CHECK:    ret i32157 158// CHECK: define internal void @[[RED_INIT1]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})159// CHECK: store float 0.000000e+00, ptr %160// CHECK: ret void161 162// CHECK: define internal void @[[RED_COMB1]](ptr noundef %0, ptr noundef %1)163// CHECK: fadd float %164// CHECK: store float %{{.+}}, ptr %165// CHECK: ret void166 167// CHECK: define internal void @[[RED_INIT2]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})168// CHECK: call void [[OMP_INIT1:@.+]](ptr169// CHECK: ret void170 171// CHECK: define internal void [[OMP_COMB1:@.+]](ptr noalias noundef %0, ptr noalias noundef %1)172// CHECK: fadd float %173 174// CHECK: define internal void [[OMP_INIT1]](ptr noalias noundef %0, ptr noalias noundef %1)175// CHECK: call void @llvm.memcpy.p0.p0.i64(176 177// CHECK: define internal void @[[RED_FINI2]](ptr noundef %0)178// CHECK: [[RED_SIZE1_ADDR:%.+]] = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 [[RED_SIZE1]]179// CHECK: load i64, ptr [[RED_SIZE1_ADDR]]180// CHECK: call void @181// CHECK: ret void182 183// CHECK: define internal void @[[RED_COMB2]](ptr noundef %0, ptr noundef %1)184// CHECK: [[RED_SIZE1_ADDR2:%.+]] = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 [[RED_SIZE1]]185// CHECK: load i64, ptr [[RED_SIZE1_ADDR2]]186// CHECK: call void [[OMP_COMB1]](187// CHECK: ret void188 189// CHECK: define internal void @[[RED_INIT3]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})190// CHECK: store float 0.000000e+00, ptr %191// CHECK: ret void192 193// CHECK: define internal void @[[RED_COMB3]](ptr noundef %0, ptr noundef %1)194// CHECK: fadd float %195// CHECK: store float %{{.+}}, ptr %196// CHECK: ret void197 198// CHECK: define internal void @[[RED_INIT4]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})199// CHECK: [[RED_SIZE2_ADDR:%.+]] = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 [[RED_SIZE2]]200// CHECK: load i64, ptr [[RED_SIZE2_ADDR]]201// CHECK: store float 0.000000e+00, ptr %202// CHECK: ret void203 204// CHECK: define internal void @[[RED_COMB4]](ptr noundef %0, ptr noundef %1)205// CHECK: [[RED_SIZE2_ADDR2:%.+]] = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 [[RED_SIZE2]]206// CHECK: load i64, ptr [[RED_SIZE2_ADDR2]]207// CHECK: fadd float %208// CHECK: store float %{{.+}}, ptr %209// CHECK: ret void210 211// CHECK: call ptr @__kmpc_task_reduction_get_th_data(212// CHECK: call ptr @__kmpc_task_reduction_get_th_data(213// CHECK: call ptr @__kmpc_task_reduction_get_th_data(214// CHECK: call ptr @__kmpc_task_reduction_get_th_data(215 216// CHECK-DAG: distinct !DISubprogram(linkageName: "[[TASK]]", scope: !217// CHECK-DAG: !DISubprogram(linkageName: "[[RED_INIT1]]"218// CHECK-DAG: !DISubprogram(linkageName: "[[RED_COMB1]]"219// CHECK-DAG: !DISubprogram(linkageName: "[[RED_INIT2]]"220// CHECK-DAG: !DISubprogram(linkageName: "[[RED_FINI2]]"221// CHECK-DAG: !DISubprogram(linkageName: "[[RED_COMB2]]"222// CHECK-DAG: !DISubprogram(linkageName: "[[RED_INIT3]]"223// CHECK-DAG: !DISubprogram(linkageName: "[[RED_COMB3]]"224// CHECK-DAG: !DISubprogram(linkageName: "[[RED_INIT4]]"225// CHECK-DAG: !DISubprogram(linkageName: "[[RED_COMB4]]"226