1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s 2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -emit-pch -o %t %s 3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-linux -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 4 5 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 8 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 9 // expected-no-diagnostics 10 #ifndef HEADER 11 #define HEADER 12 13 // CHECK: @main 14 int main(int argc, char **argv) { 15 #pragma omp parallel 16 #pragma omp sections reduction(task, +: argc, argv[0:10][0:argc]) 17 { 18 #pragma omp task in_reduction(+: argc, argv[0:10][0:argc]) 19 ; 20 } 21 } 22 23 // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*, i8***)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i32* %{{.+}}, i8*** %{{.+}}) 24 25 // CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* {{.+}}, i8*** {{.+}}) 26 // CHECK: alloca i32, 27 // CHECK: alloca i32, 28 // CHECK: alloca i32, 29 // CHECK: alloca i32, 30 // CHECK: alloca i32, 31 // CHECK: [[ARGC_FP_ADDR:%.+]] = alloca i32, 32 // CHECK: [[TR:%.+]] = alloca [2 x %struct.kmp_taskred_input_t], 33 // CHECK: [[TG:%.+]] = alloca i8*, 34 35 // Init firstprivate copy of argc 36 // CHECK: store i32 0, i32* [[ARGC_FP_ADDR]], 37 // CHECK: [[ARGV_FP_ADDR:%.+]] = alloca i8, i64 [[SIZE:%.+]], 38 // CHECK: store i64 [[SIZE]], i64* [[SIZE_ADDR:%.+]], 39 40 // Init firstprivate copy of argv[0:10][0:argc] 41 // CHECK: [[END:%.+]] = getelementptr i8, i8* [[ARGV_FP_ADDR]], i64 [[SIZE]] 42 // CHECK: [[EMPTY:%.+]] = icmp eq i8* [[ARGV_FP_ADDR]], [[END]] 43 // CHECK: br i1 [[EMPTY]], label %[[DONE:.+]], label %[[INIT:.+]] 44 // CHECK: [[INIT]]: 45 // CHECK: [[EL:%.+]] = phi i8* [ [[ARGV_FP_ADDR]], %{{.+}} ], [ [[NEXT_EL:%.+]], %[[INIT]] ] 46 // CHECK: store i8 0, i8* [[EL]], 47 // CHECK: [[NEXT_EL:%.+]] = getelementptr i8, i8* [[EL]], i32 1 48 // CHECK: [[FINISHED:%.+]] = icmp eq i8* [[NEXT_EL]], [[END]] 49 // CHECK: br i1 [[FINISHED]], label %[[DONE]], label %[[INIT]] 50 // CHECK: [[DONE]]: 51 52 // Register task reduction. 53 // CHECK: [[TR0_ADDR:%.+]] = getelementptr inbounds [2 x %struct.kmp_taskred_input_t], [2 x %struct.kmp_taskred_input_t]* [[TR]], i64 0, i64 0 54 // CHECK: [[TR0_SHARED_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR0_ADDR]], i32 0, i32 0 55 // CHECK: [[BC:%.+]] = bitcast i32* [[ARGC_FP_ADDR]] to i8* 56 // CHECK: store i8* [[BC]], i8** [[TR0_SHARED_ADDR]], 57 // CHECK: [[TR0_ORIG_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR0_ADDR]], i32 0, i32 1 58 // CHECK: [[BC:%.+]] = bitcast i32* %{{.+}} to i8* 59 // CHECK: store i8* [[BC]], i8** [[TR0_ORIG_ADDR]], 60 // CHECK: [[TR0_SIZE_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR0_ADDR]], i32 0, i32 2 61 // CHECK: store i64 4, i64* [[TR0_SIZE_ADDR]], 62 // CHECK: [[TR0_INIT_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR0_ADDR]], i32 0, i32 3 63 // CHECK: store i8* bitcast (void (i8*, i8*)* [[ARGC_INIT:@.+]] to i8*), i8** [[TR0_INIT_ADDR]], 64 // CHECK: [[TR0_FINI_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR0_ADDR]], i32 0, i32 4 65 // CHECK: store i8* null, i8** [[TR0_FINI_ADDR]], 66 // CHECK: [[TR0_COMB_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR0_ADDR]], i32 0, i32 5 67 // CHECK: store i8* bitcast (void (i8*, i8*)* [[ARGC_COMB:@.+]] to i8*), i8** [[TR0_COMB_ADDR]], 68 // CHECK: [[TR0_FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR0_ADDR]], i32 0, i32 6 69 // CHECK: [[BC:%.+]] = bitcast i32* [[TR0_FLAGS_ADDR]] to i8* 70 // CHECK: call void @llvm.memset.p0i8.i64(i8* {{.*}}[[BC]], i8 0, i64 4, i1 false) 71 // CHECK: [[TR1_ADDR:%.+]] = getelementptr inbounds [2 x %struct.kmp_taskred_input_t], [2 x %struct.kmp_taskred_input_t]* [[TR]], i64 0, i64 1 72 // CHECK: [[TR1_SHARED_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR1_ADDR]], i32 0, i32 0 73 // CHECK: store i8* [[ARGV_FP_ADDR]], i8** [[TR1_SHARED_ADDR]], 74 // CHECK: [[TR1_ORIG_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR1_ADDR]], i32 0, i32 1 75 // CHECK: store i8* %{{.+}}, i8** [[TR1_ORIG_ADDR]], 76 // CHECK: [[TR1_SIZE_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR1_ADDR]], i32 0, i32 2 77 // CHECK: store i64 %{{.+}}, i64* [[TR1_SIZE_ADDR]], 78 // CHECK: [[TR1_INIT_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR1_ADDR]], i32 0, i32 3 79 // CHECK: store i8* bitcast (void (i8*, i8*)* [[ARGV_INIT:@.+]] to i8*), i8** [[TR1_INIT_ADDR]], 80 // CHECK: [[TR1_FINI_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR1_ADDR]], i32 0, i32 4 81 // CHECK: store i8* null, i8** [[TR1_FINI_ADDR]], 82 // CHECK: [[TR1_COMB_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR1_ADDR]], i32 0, i32 5 83 // CHECK: store i8* bitcast (void (i8*, i8*)* [[ARGV_COMB:@.+]] to i8*), i8** [[TR1_COMB_ADDR]], 84 // CHECK: [[TR1_FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_taskred_input_t, %struct.kmp_taskred_input_t* [[TR1_ADDR]], i32 0, i32 6 85 // CHECK: store i32 1, i32* [[TR1_FLAGS_ADDR]], 86 // CHECK: [[BC:%.+]] = bitcast [2 x %struct.kmp_taskred_input_t]* [[TR]] to i8* 87 // CHECK: [[TG_VAL:%.+]] = call i8* @__kmpc_taskred_modifier_init(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i32 1, i32 2, i8* [[BC]]) 88 // CHECK: store i8* [[TG_VAL]], i8** [[TG]], 89 90 // CHECK: [[PTR:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i32 1, i64 48, i64 24, i32 (i32, i8*)* bitcast (i32 (i32, [[TASK_TY:%.+]]*)* [[TASK:@.+]] to i32 (i32, i8*)*)) 91 // CHECK: [[TASK_DATA_ADDR:%.+]] = bitcast i8* [[PTR]] to [[TASK_TY]]* 92 // CHECK: [[PRIVATES_ADDR:%.+]] = getelementptr inbounds [[TASK_TY]], [[TASK_TY]]* [[TASK_DATA_ADDR]], i32 0, i32 1 93 // CHECK: [[TG_PRIV_ADDR:%.+]] = getelementptr inbounds [[TASK_PRIVATES_TY:%.+]], %{{.+}}* [[PRIVATES_ADDR]], i32 0, i32 0 94 // CHECK: [[TG_VAL:%.+]] = load i8*, i8** [[TG]], 95 // CHECK: store i8* [[TG_VAL]], i8** [[TG_PRIV_ADDR]], 96 97 // CHECK: call i32 @__kmpc_omp_task(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i8* [[PTR]]) 98 99 // CHECK: call void @__kmpc_task_reduction_modifier_fini(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i32 1) 100 // CHECK: call i32 @__kmpc_reduce( 101 102 // CHECK: define internal void [[ARGC_INIT]](i8* noalias %{{.+}}, i8* noalias %{{.+}}) 103 // CHECK: store i32 0, i32* %{{.+}}, 104 105 // CHECK: define internal void [[ARGC_COMB]](i8* %{{.+}}, i8* %{{.+}}) 106 // CHECK: [[ADD:%.+]] = add nsw i32 %{{.+}}, %{{.+}} 107 // CHECK: store i32 [[ADD]], i32* %{{.+}}, 108 109 // CHECK: define internal void [[ARGV_INIT]](i8* noalias %{{.+}}, i8* noalias %{{.+}}) 110 // CHECK: phi i8* 111 // CHECK: store i8 0, i8* [[EL:%.+]], 112 // CHECK: getelementptr i8, i8* [[EL]], i32 1 113 114 // CHECK: define internal void [[ARGV_COMB]](i8* %{{.+}}, i8* %{{.+}}) 115 // CHECK: phi i8* 116 // CHECK: [[ADD:%.+]] = add nsw i32 %{{.+}}, %{{.+}} 117 // CHECK: [[CONV:%.+]] = trunc i32 [[ADD]] to i8 118 // CHECK: store i8 [[CONV]], i8* [[EL:%.+]], 119 // CHECK: getelementptr i8, i8* [[EL]], i32 1 120 121 // CHECK: define internal {{.*}}i32 [[TASK]](i32 {{.+}}, [[TASK_TY]]* {{.+}}) 122 // CHECK-DAG: call i8* @__kmpc_task_reduction_get_th_data(i32 %{{.+}}, i8* [[TG:%.+]], i8* [[ARGC_REF:%.+]]) 123 // CHECK_DAG: [[TG]] = load i8*, i8** [[TG_ADDR:%.+]], 124 // CHECK-DAG: [[ARGC_REF]] = bitcast i32* [[ARGC_ADDR:%.+]] to i8* 125 // CHECK-DAG: [[ARGC_ADDR]] = load i32*, i32** [[ARGC_ADDR_REF:%.+]], 126 // CHECK-DAG: [[ARGC_ADDR_REF]] = getelementptr inbounds [[CAPS_TY:%.+]], %{{.+}}* [[CAP:%.+]], i32 0, i32 1 127 // CHECK-DAG: call i8* @__kmpc_task_reduction_get_th_data(i32 %{{.+}}, i8* [[TG:%.+]], i8* [[ARGV_REF:%.+]]) 128 // CHECK_DAG: [[TG]] = load i8*, i8** [[TG_ADDR]], 129 // CHECK-DAG: [[ARGV_REF]] = load i8*, i8** [[ARGV_ADDR:%.+]], 130 // CHECK-DAG: [[ARGV_ADDR]] = load i8**, i8*** [[ARGV_ADDR_REF:%.+]], 131 // CHECK-DAG: [[ARGV_ADDR_REF:%.+]] = load i8***, i8**** [[ARGV:%.+]], 132 // CHECK-DAG: [[ARGV]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2 133 134 #endif 135