Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s |
| 2 | // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s |
| 3 | // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s |
Alexey Bataev | 36bf011 | 2015-03-10 05:15:26 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp=libiomp5 -fexceptions -fcxx-exceptions -gline-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 5 | // expected-no-diagnostics |
Adrian Prantl | cbc368c | 2015-02-25 02:44:04 +0000 | [diff] [blame] | 6 | |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 7 | #ifndef HEADER |
| 8 | #define HEADER |
| 9 | |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 10 | class TestClass { |
| 11 | public: |
| 12 | int a; |
| 13 | TestClass() : a(0) {} |
| 14 | TestClass(const TestClass &C) : a(C.a) {} |
| 15 | TestClass &operator=(const TestClass &) { return *this;} |
| 16 | ~TestClass(){}; |
| 17 | }; |
| 18 | |
| 19 | // CHECK-DAG: [[TEST_CLASS_TY:%.+]] = type { i{{[0-9]+}} } |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 20 | // CHECK: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } |
| 21 | |
| 22 | // CHECK: define void [[FOO:@.+]]() |
| 23 | |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 24 | TestClass tc; |
| 25 | #pragma omp threadprivate(tc) |
| 26 | |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 27 | void foo() {} |
| 28 | |
| 29 | // CHECK-LABEL: @main |
Alexey Bataev | 36bf011 | 2015-03-10 05:15:26 +0000 | [diff] [blame] | 30 | // TERM_DEBUG-LABEL: @main |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 31 | int main() { |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 32 | // CHECK-DAG: [[A_ADDR:%.+]] = alloca i8 |
| 33 | // CHECK-DAG: [[C_ADDR:%.+]] = alloca [[TEST_CLASS_TY]] |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 34 | char a; |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 35 | TestClass c; |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 36 | |
| 37 | // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]]) |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 38 | // CHECK-DAG: [[DID_IT:%.+]] = alloca i32, |
| 39 | // CHECK-DAG: [[COPY_LIST:%.+]] = alloca [3 x i8*], |
| 40 | // CHECK: store i32 0, i32* [[DID_IT]] |
| 41 | |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 42 | // CHECK: [[RES:%.+]] = call i32 @__kmpc_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) |
| 43 | // CHECK-NEXT: [[IS_SINGLE:%.+]] = icmp ne i32 [[RES]], 0 |
| 44 | // CHECK-NEXT: br i1 [[IS_SINGLE]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] |
| 45 | // CHECK: [[THEN]] |
| 46 | // CHECK-NEXT: store i8 2, i8* [[A_ADDR]] |
| 47 | // CHECK-NEXT: call void @__kmpc_end_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) |
| 48 | // CHECK-NEXT: br label {{%?}}[[EXIT]] |
| 49 | // CHECK: [[EXIT]] |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 50 | #pragma omp single nowait |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 51 | a = 2; |
| 52 | // CHECK: [[RES:%.+]] = call i32 @__kmpc_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) |
| 53 | // CHECK-NEXT: [[IS_SINGLE:%.+]] = icmp ne i32 [[RES]], 0 |
| 54 | // CHECK-NEXT: br i1 [[IS_SINGLE]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]] |
| 55 | // CHECK: [[THEN]] |
Alexey Bataev | 36bf011 | 2015-03-10 05:15:26 +0000 | [diff] [blame] | 56 | // CHECK-NEXT: invoke void [[FOO]]() |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 57 | // CHECK: to label {{%?}}[[CONT:.+]] unwind |
| 58 | // CHECK: [[CONT]] |
| 59 | // CHECK: store i32 1, i32* [[DID_IT]] |
Alexey Bataev | 36bf011 | 2015-03-10 05:15:26 +0000 | [diff] [blame] | 60 | // CHECK: call void @__kmpc_end_single([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]]) |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 61 | // CHECK-NEXT: br label {{%?}}[[EXIT]] |
| 62 | // CHECK: [[EXIT]] |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 63 | // CHECK: [[A_PTR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[COPY_LIST]], i{{[0-9]+}} 0, i{{[0-9]+}} 0 |
| 64 | // CHECK: store i8* [[A_ADDR]], i8** [[A_PTR_REF]], |
| 65 | // CHECK: [[C_PTR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[COPY_LIST]], i{{[0-9]+}} 0, i{{[0-9]+}} 1 |
| 66 | // CHECK: [[C_PTR_REF_VOID_PTR:%.+]] = bitcast [[TEST_CLASS_TY]]* [[C_ADDR]] to i8* |
| 67 | // CHECK: store i8* [[C_PTR_REF_VOID_PTR]], i8** [[C_PTR_REF]], |
| 68 | // CHECK: [[TC_PTR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[COPY_LIST]], i{{[0-9]+}} 0, i{{[0-9]+}} 2 |
| 69 | // CHECK: [[TC_THREADPRIVATE_ADDR_VOID_PTR:%.+]] = call{{.*}} i8* @__kmpc_threadprivate_cached |
| 70 | // CHECK: [[TC_THREADPRIVATE_ADDR:%.+]] = bitcast i8* [[TC_THREADPRIVATE_ADDR_VOID_PTR]] to [[TEST_CLASS_TY]]* |
| 71 | // CHECK: [[TC_PTR_REF_VOID_PTR:%.+]] = bitcast [[TEST_CLASS_TY]]* [[TC_THREADPRIVATE_ADDR]] to i8* |
| 72 | // CHECK: store i8* [[TC_PTR_REF_VOID_PTR]], i8** [[TC_PTR_REF]], |
| 73 | // CHECK: [[COPY_LIST_VOID_PTR:%.+]] = bitcast [3 x i8*]* [[COPY_LIST]] to i8* |
| 74 | // CHECK: [[DID_IT_VAL:%.+]] = load i32, i32* [[DID_IT]], |
| 75 | // CHECK: call void @__kmpc_copyprivate([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], i32 24, i8* [[COPY_LIST_VOID_PTR]], void (i8*, i8*)* [[COPY_FUNC:@.+]], i32 [[DID_IT_VAL]]) |
| 76 | // CHECK: call{{.*}} @__kmpc_cancel_barrier([[IDENT_T_TY]]* {{@.+}}, i32 [[GTID]]) |
| 77 | #pragma omp single copyprivate(a, c, tc) |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 78 | foo(); |
| 79 | // CHECK-NOT: call i32 @__kmpc_single |
| 80 | // CHECK-NOT: call void @__kmpc_end_single |
| 81 | return a; |
| 82 | } |
| 83 | |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 84 | // CHECK: void [[COPY_FUNC]](i8*, i8*) |
| 85 | // CHECK: store i8* %0, i8** [[DST_ADDR_REF:%.+]], |
| 86 | // CHECK: store i8* %1, i8** [[SRC_ADDR_REF:%.+]], |
| 87 | // CHECK: [[DST_ADDR_VOID_PTR:%.+]] = load i8*, i8** [[DST_ADDR_REF]], |
| 88 | // CHECK: [[DST_ADDR:%.+]] = bitcast i8* [[DST_ADDR_VOID_PTR]] to [3 x i8*]* |
| 89 | // CHECK: [[SRC_ADDR_VOID_PTR:%.+]] = load i8*, i8** [[SRC_ADDR_REF]], |
| 90 | // CHECK: [[SRC_ADDR:%.+]] = bitcast i8* [[SRC_ADDR_VOID_PTR]] to [3 x i8*]* |
| 91 | // CHECK: [[SRC_A_ADDR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[SRC_ADDR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0 |
| 92 | // CHECK: [[SRC_A_ADDR:%.+]] = load i8*, i8** [[SRC_A_ADDR_REF]], |
| 93 | // CHECK: [[DST_A_ADDR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[DST_ADDR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0 |
| 94 | // CHECK: [[DST_A_ADDR:%.+]] = load i8*, i8** [[DST_A_ADDR_REF]], |
| 95 | // CHECK: [[SRC_C_ADDR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[SRC_ADDR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1 |
| 96 | // CHECK: [[SRC_C_ADDR_VOID_PTR:%.+]] = load i8*, i8** [[SRC_C_ADDR_REF]], |
| 97 | // CHECK: [[SRC_C_ADDR:%.+]] = bitcast i8* [[SRC_C_ADDR_VOID_PTR:%.+]] to [[TEST_CLASS_TY]]* |
| 98 | // CHECK: [[DST_C_ADDR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[DST_ADDR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1 |
| 99 | // CHECK: [[DST_C_ADDR_VOID_PTR:%.+]] = load i8*, i8** [[DST_C_ADDR_REF]], |
| 100 | // CHECK: [[DST_C_ADDR:%.+]] = bitcast i8* [[DST_C_ADDR_VOID_PTR:%.+]] to [[TEST_CLASS_TY]]* |
| 101 | // CHECK: [[SRC_TC_ADDR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[SRC_ADDR]], i{{[0-9]+}} 0, i{{[0-9]+}} 2 |
| 102 | // CHECK: [[SRC_TC_ADDR_VOID_PTR:%.+]] = load i8*, i8** [[SRC_TC_ADDR_REF]], |
| 103 | // CHECK: [[SRC_TC_ADDR:%.+]] = bitcast i8* [[SRC_TC_ADDR_VOID_PTR:%.+]] to [[TEST_CLASS_TY]]* |
| 104 | // CHECK: [[DST_TC_ADDR_REF:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[DST_ADDR]], i{{[0-9]+}} 0, i{{[0-9]+}} 2 |
| 105 | // CHECK: [[DST_TC_ADDR_VOID_PTR:%.+]] = load i8*, i8** [[DST_TC_ADDR_REF]], |
| 106 | // CHECK: [[DST_TC_ADDR:%.+]] = bitcast i8* [[DST_TC_ADDR_VOID_PTR:%.+]] to [[TEST_CLASS_TY]]* |
| 107 | // CHECK: [[SRC_A_VAL:%.+]] = load i8, i8* [[SRC_A_ADDR]], |
| 108 | // CHECK: store i8 [[SRC_A_VAL]], i8* [[DST_A_ADDR]], |
| 109 | // CHECK: call{{.*}} [[TEST_CLASS_TY_ASSIGN:@.+]]([[TEST_CLASS_TY]]* [[DST_C_ADDR]], [[TEST_CLASS_TY]]* {{.*}}[[SRC_C_ADDR]]) |
| 110 | // CHECK: call{{.*}} [[TEST_CLASS_TY_ASSIGN:@.+]]([[TEST_CLASS_TY]]* [[DST_TC_ADDR]], [[TEST_CLASS_TY]]* {{.*}}[[SRC_TC_ADDR]]) |
| 111 | // CHECK: ret void |
| 112 | |
Alexey Bataev | 36bf011 | 2015-03-10 05:15:26 +0000 | [diff] [blame] | 113 | // CHECK-LABEL: parallel_single |
| 114 | // TERM_DEBUG-LABEL: parallel_single |
| 115 | void parallel_single() { |
Alexey Bataev | 8cbe0a6 | 2015-02-26 10:27:34 +0000 | [diff] [blame] | 116 | #pragma omp parallel |
| 117 | #pragma omp single |
Alexey Bataev | 36bf011 | 2015-03-10 05:15:26 +0000 | [diff] [blame] | 118 | // TERM_DEBUG-NOT: __kmpc_global_thread_num |
| 119 | // TERM_DEBUG: call i32 @__kmpc_single({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]] |
| 120 | // TERM_DEBUG: invoke void {{.*}}foo{{.*}}() |
| 121 | // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]], |
| 122 | // TERM_DEBUG-NOT: __kmpc_global_thread_num |
| 123 | // TERM_DEBUG: call void @__kmpc_end_single({{.+}}), !dbg [[DBG_LOC_END:![0-9]+]] |
Alexey Bataev | da19af4 | 2015-03-10 05:28:46 +0000 | [diff] [blame] | 124 | // TERM_DEBUG: [[TERM_LPAD]] |
Alexey Bataev | 36bf011 | 2015-03-10 05:15:26 +0000 | [diff] [blame] | 125 | // TERM_DEBUG: call void @__clang_call_terminate |
| 126 | // TERM_DEBUG: unreachable |
| 127 | foo(); |
Alexey Bataev | 8cbe0a6 | 2015-02-26 10:27:34 +0000 | [diff] [blame] | 128 | } |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame^] | 129 | // TERM_DEBUG-DAG: [[DBG_LOC_START]] = !MDLocation(line: [[@LINE-12]], |
| 130 | // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !MDLocation(line: [[@LINE-13]], |
Alexey Bataev | 8cbe0a6 | 2015-02-26 10:27:34 +0000 | [diff] [blame] | 131 | |
Alexey Bataev | 6956e2e | 2015-02-05 06:35:41 +0000 | [diff] [blame] | 132 | #endif |