1 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-version=50 -emit-llvm -o - %s | FileCheck %s 2 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10 -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s 3 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10 -fopenmp-version=50 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 4 5 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fopenmp-version=50 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s 6 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10 -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s 7 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10 -fopenmp-version=50 -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 11 #ifndef HEADER 12 #define HEADER 13 14 // CHECK-DAG: [[MAIN_A:@.+]] = internal global i8* null, 15 // CHECK-DAG: [[TMAIN_A:@.+]] = linkonce_odr global i8* null, 16 17 typedef void *omp_depend_t; 18 19 void foo() {} 20 21 template <class T> 22 T tmain(T argc) { 23 static T a; 24 void *argv; 25 #pragma omp depobj(a) depend(in:argv) 26 #pragma omp depobj(argc) destroy 27 #pragma omp depobj(argc) update(inout) 28 return argc; 29 } 30 31 int main(int argc, char **argv) { 32 static omp_depend_t a; 33 omp_depend_t b; 34 #pragma omp depobj(a) depend(out:argc, argv) 35 #pragma omp depobj(b) destroy 36 #pragma omp depobj(b) update(mutexinoutset) 37 (void)tmain(a), tmain(b); 38 return 0; 39 } 40 41 // CHECK-LABEL: @main 42 // CHECK: [[B_ADDR:%.+]] = alloca i8*, 43 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num( 44 // CHECK: [[DEP_ADDR_VOID:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 72, i8* null) 45 // CHECK: [[DEP_ADDR:%.+]] = bitcast i8* [[DEP_ADDR_VOID]] to [3 x %struct.kmp_depend_info]* 46 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 0 47 // CHECK: [[SZ_BASE:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0 48 // CHECK: store i64 2, i64* [[SZ_BASE]], 49 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 1 50 // CHECK: [[ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0 51 // CHECK: store i64 %{{.+}}, i64* [[ADDR]], 52 // CHECK: [[SZ_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 1 53 // CHECK: store i64 4, i64* [[SZ_ADDR]], 54 // CHECK: [[FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 2 55 // CHECK: store i8 3, i8* [[FLAGS_ADDR]], 56 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 2 57 // CHECK: [[ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0 58 // CHECK: store i64 %{{.+}}, i64* [[ADDR]], 59 // CHECK: [[SZ_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 1 60 // CHECK: store i64 8, i64* [[SZ_ADDR]], 61 // CHECK: [[FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 2 62 // CHECK: store i8 3, i8* [[FLAGS_ADDR]], 63 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 1 64 // CHECK: [[DEP:%.+]] = bitcast %struct.kmp_depend_info* [[BASE_ADDR]] to i8* 65 // CHECK: store i8* [[DEP]], i8** [[MAIN_A]], 66 // CHECK: [[B:%.+]] = load i8*, i8** [[B_ADDR]], 67 // CHECK: [[B_BASE:%.+]] = bitcast i8* [[B]] to %struct.kmp_depend_info* 68 // CHECK: [[B_REF:%.+]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[B_BASE]], i{{.+}} -1 69 // CHECK: [[B:%.+]] = bitcast %struct.kmp_depend_info* [[B_REF]] to i8* 70 // CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[B]], i8* null) 71 // CHECK: [[B:%.+]] = load i8*, i8** [[B_ADDR]], 72 // CHECK: [[B_BASE:%.+]] = bitcast i8* [[B]] to %struct.kmp_depend_info* 73 // CHECK: [[NUMDEPS_BASE:%.+]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[B_BASE]], i64 -1 74 // CHECK: [[NUMDEPS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[NUMDEPS_BASE]], i{{.+}} 0, i{{.+}} 0 75 // CHECK: [[NUMDEPS:%.+]] = load i64, i64* [[NUMDEPS_ADDR]], 76 // CHECK: [[END:%.+]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[B_BASE]], i64 [[NUMDEPS]] 77 // CHECK: br label %[[BODY:.+]] 78 // CHECK: [[BODY]]: 79 // CHECK: [[EL:%.+]] = phi %struct.kmp_depend_info* [ [[B_BASE]], %{{.+}} ], [ [[EL_NEXT:%.+]], %[[BODY]] ] 80 // CHECK: [[FLAG_BASE:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[EL]], i{{.+}} 0, i{{.+}} 2 81 // CHECK: store i8 4, i8* [[FLAG_BASE]], 82 // CHECK: [[EL_NEXT]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[EL]], i{{.+}} 1 83 // CHECK: [[IS_DONE:%.+]] = icmp eq %struct.kmp_depend_info* [[EL_NEXT]], [[END]] 84 // CHECK: br i1 [[IS_DONE]], label %[[DONE:.+]], label %[[BODY]] 85 // CHECK: [[DONE]]: 86 87 // CHECK-LABEL: tmain 88 // CHECK: [[ARGC_ADDR:%.+]] = alloca i8*, 89 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num( 90 // CHECK: [[DEP_ADDR_VOID:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 48, i8* null) 91 // CHECK: [[DEP_ADDR:%.+]] = bitcast i8* [[DEP_ADDR_VOID]] to [2 x %struct.kmp_depend_info]* 92 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [2 x %struct.kmp_depend_info], [2 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 0 93 // CHECK: [[SZ_BASE:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0 94 // CHECK: store i64 1, i64* [[SZ_BASE]], 95 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [2 x %struct.kmp_depend_info], [2 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 1 96 // CHECK: [[ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0 97 // CHECK: store i64 %{{.+}}, i64* [[ADDR]], 98 // CHECK: [[SZ_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 1 99 // CHECK: store i64 8, i64* [[SZ_ADDR]], 100 // CHECK: [[FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 2 101 // CHECK: store i8 1, i8* [[FLAGS_ADDR]], 102 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [2 x %struct.kmp_depend_info], [2 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 1 103 // CHECK: [[DEP:%.+]] = bitcast %struct.kmp_depend_info* [[BASE_ADDR]] to i8* 104 // CHECK: store i8* [[DEP]], i8** [[TMAIN_A]], 105 // CHECK: [[ARGC:%.+]] = load i8*, i8** [[ARGC_ADDR]], 106 // CHECK: [[ARGC_BASE:%.+]] = bitcast i8* [[ARGC]] to %struct.kmp_depend_info* 107 // CHECK: [[ARGC_REF:%.+]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[ARGC_BASE]], i{{.+}} -1 108 // CHECK: [[ARGC:%.+]] = bitcast %struct.kmp_depend_info* [[ARGC_REF]] to i8* 109 // CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[ARGC]], i8* null) 110 // CHECK: [[ARGC:%.+]] = load i8*, i8** [[ARGC_ADDR]], 111 // CHECK: [[ARGC_BASE:%.+]] = bitcast i8* [[ARGC]] to %struct.kmp_depend_info* 112 // CHECK: [[NUMDEPS_BASE:%.+]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[ARGC_BASE]], i64 -1 113 // CHECK: [[NUMDEPS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[NUMDEPS_BASE]], i{{.+}} 0, i{{.+}} 0 114 // CHECK: [[NUMDEPS:%.+]] = load i64, i64* [[NUMDEPS_ADDR]], 115 // CHECK: [[END:%.+]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[ARGC_BASE]], i64 [[NUMDEPS]] 116 // CHECK: br label %[[BODY:.+]] 117 // CHECK: [[BODY]]: 118 // CHECK: [[EL:%.+]] = phi %struct.kmp_depend_info* [ [[ARGC_BASE]], %{{.+}} ], [ [[EL_NEXT:%.+]], %[[BODY]] ] 119 // CHECK: [[FLAG_BASE:%.+]] = getelementptr inbounds %struct.kmp_depend_info, %struct.kmp_depend_info* [[EL]], i{{.+}} 0, i{{.+}} 2 120 // CHECK: store i8 3, i8* [[FLAG_BASE]], 121 // CHECK: [[EL_NEXT]] = getelementptr %struct.kmp_depend_info, %struct.kmp_depend_info* [[EL]], i{{.+}} 1 122 // CHECK: [[IS_DONE:%.+]] = icmp eq %struct.kmp_depend_info* [[EL_NEXT]], [[END]] 123 // CHECK: br i1 [[IS_DONE]], label %[[DONE:.+]], label %[[BODY]] 124 // CHECK: [[DONE]]: 125 126 #endif 127