123 lines · c
1// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py2// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER3// %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o /tmp/t1 %s4// %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch /tmp/t1 -verify %s -emit-llvm -o - | FileCheck --check-prefixes=ALL-DEBUG,IRBUILDER-DEBUG %s5 6// expected-no-diagnostics7 8// TODO: Teach the update script to check new functions too.9 10#ifndef HEADER11#define HEADER12 13// ALL-LABEL: @_Z17nested_parallel_0v(14// ALL-NEXT: entry:15// ALL-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])16// ALL-NEXT: br label [[OMP_PARALLEL:%.*]]17// ALL: omp_parallel:18// ALL-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1]], i32 0, ptr @_Z17nested_parallel_0v..omp_par.1)19// ALL-NEXT: br label [[OMP_PAR_EXIT:%.*]]20// ALL: omp.par.exit7:21// ALL-NEXT: br label [[OMP_PAR_EXIT_SPLIT:%.*]]22// ALL: omp.par.exit.exitStub:23// ALL-NEXT: ret void24//25void nested_parallel_0(void) {26#pragma omp parallel27 {28#pragma omp parallel29 {30 }31 }32}33 34// ALL-LABEL: @_Z17nested_parallel_1Pfid(35// ALL-NEXT: entry:36// ALL-NEXT: [[STRUCTARG14:%.*]] = alloca { ptr, ptr, ptr }, align 837// ALL-NEXT: [[R_ADDR:%.*]] = alloca ptr, align 838// ALL-NEXT: [[A_ADDR:%.*]] = alloca i32, align 439// ALL-NEXT: [[B_ADDR:%.*]] = alloca double, align 840// ALL-NEXT: store ptr [[R:%.*]], ptr [[R_ADDR]], align 841// ALL-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 442// ALL-NEXT: store double [[B:%.*]], ptr [[B_ADDR]], align 843// ALL-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1]])44// ALL-NEXT: br label [[OMP_PARALLEL:%.*]]45// ALL: omp_parallel:46// ALL-NEXT: [[GEP_A_ADDR15:%.*]] = getelementptr { ptr, ptr, ptr }, ptr [[STRUCTARG14]], i32 0, i32 047// ALL-NEXT: store ptr [[A_ADDR]], ptr [[GEP_A_ADDR15]], align 848// ALL-NEXT: [[GEP_B_ADDR16:%.*]] = getelementptr { ptr, ptr, ptr }, ptr [[STRUCTARG14]], i32 0, i32 149// ALL-NEXT: store ptr [[B_ADDR]], ptr [[GEP_B_ADDR16]], align 850// ALL-NEXT: [[GEP_R_ADDR17:%.*]] = getelementptr { ptr, ptr, ptr }, ptr [[STRUCTARG14]], i32 0, i32 251// ALL-NEXT: store ptr [[R_ADDR]], ptr [[GEP_R_ADDR17]], align 852// ALL-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1]], i32 1, ptr @_Z17nested_parallel_1Pfid..omp_par.2, ptr [[STRUCTARG14]])53// ALL-NEXT: br label [[OMP_PAR_EXIT:%.*]]54// ALL: omp.par.exit:55// ALL-NEXT: ret void56//57void nested_parallel_1(float *r, int a, double b) {58#pragma omp parallel59 {60#pragma omp parallel61 {62 *r = a + b;63 }64 }65}66 67// ALL-LABEL: @_Z17nested_parallel_2Pfid(68// ALL-NEXT: entry:69// ALL-NEXT: [[STRUCTARG:%.*]] = alloca { ptr, ptr, ptr }, align 870// ALL-NEXT: [[R_ADDR:%.*]] = alloca ptr, align 871// ALL-NEXT: [[A_ADDR:%.*]] = alloca i32, align 472// ALL-NEXT: [[B_ADDR:%.*]] = alloca double, align 873// ALL-NEXT: store ptr [[R:%.*]], ptr [[R_ADDR]], align 874// ALL-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 475// ALL-NEXT: store double [[B:%.*]], ptr [[B_ADDR]], align 876// ALL-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1]])77// ALL-NEXT: br label [[OMP_PARALLEL:%.*]]78// ALL: omp_parallel:79// ALL-NEXT: [[GEP_A_ADDR:%.*]] = getelementptr { ptr, ptr, ptr }, ptr [[STRUCTARG]], i32 0, i32 080// ALL-NEXT: store ptr [[A_ADDR]], ptr [[GEP_A_ADDR]], align 881// ALL-NEXT: [[GEP_B_ADDR:%.*]] = getelementptr { ptr, ptr, ptr }, ptr [[STRUCTARG]], i32 0, i32 182// ALL-NEXT: store ptr [[B_ADDR]], ptr [[GEP_B_ADDR]], align 883// ALL-NEXT: [[GEP_R_ADDR:%.*]] = getelementptr { ptr, ptr, ptr }, ptr [[STRUCTARG]], i32 0, i32 284// ALL-NEXT: store ptr [[R_ADDR]], ptr [[GEP_R_ADDR]], align 885// ALL-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1]], i32 1, ptr @_Z17nested_parallel_2Pfid..omp_par.5, ptr [[STRUCTARG]])86// ALL-NEXT: br label [[OMP_PAR_EXIT:%.*]]87// ALL: omp.par.exit:88// ALL-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 489// ALL-NEXT: [[CONV56:%.*]] = sitofp i32 [[TMP0]] to double90// ALL-NEXT: [[TMP1:%.*]] = load double, ptr [[B_ADDR]], align 891// ALL-NEXT: [[ADD57:%.*]] = fadd double [[CONV56]], [[TMP1]]92// ALL-NEXT: [[CONV58:%.*]] = fptrunc double [[ADD57]] to float93// ALL-NEXT: [[TMP2:%.*]] = load ptr, ptr [[R_ADDR]], align 894// ALL-NEXT: store float [[CONV58]], ptr [[TMP2]], align 495// ALL-NEXT: ret void96//97void nested_parallel_2(float *r, int a, double b) {98#pragma omp parallel99 {100 *r = a + b;101#pragma omp parallel102 {103 *r = a + b;104#pragma omp parallel105 {106 *r = a + b;107 }108 *r = a + b;109#pragma omp parallel110 {111 *r = a + b;112 }113 *r = a + b;114 }115 *r = a + b;116 }117 *r = a + b;118}119 120#endif121//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:122// IRBUILDER: {{.*}}123