1 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s 2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s 3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s 4 // expected-no-diagnostics 5 // REQUIRES: x86-registered-target 6 #ifndef HEADER 7 #define HEADER 8 9 int main (int argc, char **argv) { 10 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num( 11 #pragma omp parallel 12 { 13 #pragma omp cancellation point parallel 14 #pragma omp cancel parallel 15 argv[0][0] = argc; 16 } 17 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( 18 #pragma omp sections 19 { 20 { 21 #pragma omp cancellation point sections 22 #pragma omp cancel sections 23 } 24 } 25 // CHECK: call i32 @__kmpc_single( 26 // CHECK-NOT: @__kmpc_cancellationpoint 27 // CHECK: call void @__kmpc_end_single( 28 // CHECK: call void @__kmpc_barrier(%ident_t* 29 #pragma omp sections 30 { 31 #pragma omp cancellation point sections 32 #pragma omp section 33 { 34 #pragma omp cancellation point sections 35 #pragma omp cancel sections 36 } 37 } 38 // CHECK: call void @__kmpc_for_static_init_4( 39 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3) 40 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 41 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] 42 // CHECK: [[EXIT]] 43 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 44 // CHECK: br label 45 // CHECK: [[CONTINUE]] 46 // CHECK: br label 47 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3) 48 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 49 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] 50 // CHECK: [[EXIT]] 51 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 52 // CHECK: br label 53 // CHECK: [[CONTINUE]] 54 // CHECK: br label 55 // CHECK: call void @__kmpc_for_static_fini( 56 #pragma omp for 57 for (int i = 0; i < argc; ++i) { 58 #pragma omp cancellation point for 59 #pragma omp cancel for 60 } 61 // CHECK: call void @__kmpc_for_static_init_4( 62 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 2) 63 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 64 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] 65 // CHECK: [[EXIT]] 66 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 67 // CHECK: br label 68 // CHECK: [[CONTINUE]] 69 // CHECK: br label 70 // CHECK: call void @__kmpc_for_static_fini( 71 // CHECK: call void @__kmpc_barrier(%ident_t* 72 #pragma omp task 73 { 74 #pragma omp cancellation point taskgroup 75 #pragma omp cancel taskgroup 76 } 77 // CHECK: call i8* @__kmpc_omp_task_alloc( 78 // CHECK: call i32 @__kmpc_omp_task( 79 #pragma omp parallel sections 80 { 81 { 82 #pragma omp cancellation point sections 83 #pragma omp cancel sections 84 } 85 } 86 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( 87 #pragma omp parallel sections 88 { 89 { 90 #pragma omp cancellation point sections 91 #pragma omp cancel sections 92 } 93 #pragma omp section 94 { 95 #pragma omp cancellation point sections 96 } 97 } 98 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( 99 #pragma omp parallel for 100 for (int i = 0; i < argc; ++i) { 101 #pragma omp cancellation point for 102 #pragma omp cancel for 103 } 104 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( 105 return argc; 106 } 107 108 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}}, 109 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 1) 110 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 111 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]], 112 // CHECK: [[EXIT]] 113 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 114 // CHECK: br label %[[RETURN:.+]] 115 // CHECK: [[RETURN]] 116 // CHECK: ret void 117 118 // CHECK: define internal i32 @{{[^(]+}}(i32 119 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 4) 120 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 121 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]], 122 // CHECK: [[EXIT]] 123 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 124 // CHECK: br label %[[RETURN:.+]] 125 // CHECK: [[RETURN]] 126 // CHECK: ret i32 0 127 128 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}}) 129 // CHECK: call i32 @__kmpc_single( 130 // CHECK-NOT: @__kmpc_cancellationpoint 131 // CHECK: call void @__kmpc_end_single( 132 // CHECK: ret void 133 134 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}}) 135 // CHECK: call void @__kmpc_for_static_init_4( 136 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 3) 137 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 138 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] 139 // CHECK: [[EXIT]] 140 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 141 // CHECK: br label 142 // CHECK: [[CONTINUE]] 143 // CHECK: br label 144 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3) 145 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 146 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] 147 // CHECK: [[EXIT]] 148 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 149 // CHECK: br label 150 // CHECK: [[CONTINUE]] 151 // CHECK: br label 152 // CHECK: call void @__kmpc_for_static_fini( 153 // CHECK: ret void 154 155 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}}, 156 // CHECK: call void @__kmpc_for_static_init_4( 157 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 2) 158 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 159 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] 160 // CHECK: [[EXIT]] 161 // CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* 162 // CHECK: br label 163 // CHECK: [[CONTINUE]] 164 // CHECK: br label 165 // CHECK: call void @__kmpc_for_static_fini( 166 // CHECK: ret void 167 168 #endif 169