117 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,NORMAL2// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s3// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,NORMAL4// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG5// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER6// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s7// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER8 9// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s10// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s11// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s12// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s13// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}14// expected-no-diagnostics15#ifndef HEADER16#define HEADER17 18// ALL: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }19 20// ALL: define {{.*}}void [[FOO:@.+]]()21 22void foo() { extern void mayThrow(); mayThrow(); }23 24// ALL-LABEL: @main25// TERM_DEBUG-LABEL: @main26int main() {27 // ALL: [[A_ADDR:%.+]] = alloca i828 char a;29 30// ALL: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEFAULT_LOC:@.+]])31// ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master(ptr [[DEFAULT_LOC]], i32 [[GTID]])32// ALL-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 033// ALL-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]34// ALL: [[THEN]]35// ALL-NEXT: store i8 2, ptr [[A_ADDR]]36// IRBUILDER-NEXT: br label %[[AFTER:[^ ,]+]]37// IRBUILDER: [[AFTER]]38// IRBUILDER-NEXT: br label %[[OMP_REGION_FINALIZE:[^ ,]+]]39// IRBUILDER: [[OMP_REGION_FINALIZE]]40// ALL-NEXT: call {{.*}}void @__kmpc_end_master(ptr [[DEFAULT_LOC]], i32 [[GTID]])41// ALL-NEXT: br label {{%?}}[[EXIT]]42// ALL: [[EXIT]]43#pragma omp master44 a = 2;45// IRBUILDER: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(ptr [[DEFAULT_LOC:@.+]])46// ALL: [[RES:%.+]] = call {{.*}}i32 @__kmpc_master(ptr [[DEFAULT_LOC]], i32 [[GTID]])47// ALL-NEXT: [[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 048// ALL-NEXT: br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]49// ALL: [[THEN]]50// IRBUILDER-NEXT: call {{.*}}void [[FOO]]()51// NORMAL-NEXT: invoke {{.*}}void [[FOO]]()52// ALL: call {{.*}}void @__kmpc_end_master(ptr [[DEFAULT_LOC]], i32 [[GTID]])53// ALL-NEXT: br label {{%?}}[[EXIT]]54// ALL: [[EXIT]]55#pragma omp master56 foo();57 // ALL-NOT: call i32 @__kmpc_master58 // ALL-NOT: call void @__kmpc_end_master59 return a;60}61 62// ALL-LABEL: lambda_master63// TERM_DEBUG-LABEL: lambda_master64void lambda_master(int a, int b) {65 auto l = [=]() {66#pragma omp master67 {68 // ALL: call i32 @__kmpc_master(69 int c = a + b;70 }71 };72 73 l();74 75 auto l1 = [=]() {76#pragma omp parallel77#pragma omp master78 {79 // ALL: call i32 @__kmpc_master(80 int c = a + b;81 }82 };83 84 l1();85 86 auto l2 = [=]() {87#pragma omp parallel master88 {89 // ALL: call i32 @__kmpc_master(90 int c = a + b;91 }92 };93 94 l2();95}96 97// ALL-LABEL: parallel_master98// TERM_DEBUG-LABEL: parallel_master99void parallel_master() {100#pragma omp parallel101#pragma omp master102 // TERM_DEBUG-NOT: __kmpc_global_thread_num103 // TERM_DEBUG: call i32 @__kmpc_master({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]]104 // TERM_DEBUG: invoke void {{.*}}foo{{.*}}()105 // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]],106 // TERM_DEBUG-NOT: __kmpc_global_thread_num107 // TERM_DEBUG: call void @__kmpc_end_master({{.+}}), !dbg [[DBG_LOC_END:![0-9]+]]108 // TERM_DEBUG: [[TERM_LPAD]]109 // TERM_DEBUG: call void @__clang_call_terminate110 // TERM_DEBUG: unreachable111 foo();112}113// TERM_DEBUG-DAG: [[DBG_LOC_START]] = !DILocation(line: [[@LINE-12]],114// TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-3]],115 116#endif117