Files
clang-p2996/clang/test/OpenMP/metadirective_empty.cpp
alokmishra.besu 000875c127 OpenMP 5.0 metadirective
This patch supports OpenMP 5.0 metadirective features.
It is implemented keeping the OpenMP 5.1 features like dynamic user condition in mind.

A new function, getBestWhenMatchForContext, is defined in llvm/Frontend/OpenMP/OMPContext.h

Currently this function return the index of the when clause with the highest score from the ones applicable in the Context.
But this function is declared with an array which can be used in OpenMP 5.1 implementation to select all the valid when clauses which can be resolved in runtime. Currently this array is set to null by default and its implementation is left for future.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D91944
2021-09-18 13:40:44 -05:00

40 lines
1.5 KiB
C++

// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
// expected-no-diagnostics
#ifndef HEADER
#define HEADER
#define N 1000
void func() {
// Test where a valid when clause contains empty directive.
// The directive will be ignored and code for a serial for loop will be generated.
#pragma omp metadirective when(implementation = {vendor(llvm)} \
:) default(parallel for)
for (int i = 0; i < N; i++)
;
}
// CHECK-LABEL: void @_Z4funcv()
// CHECK: entry:
// CHECK: [[I:%.+]] = alloca i32,
// CHECK: store i32 0, i32* [[I]],
// CHECK: br label %[[FOR_COND:.+]]
// CHECK: [[FOR_COND]]:
// CHECK: [[ZERO:%.+]] = load i32, i32* [[I]],
// CHECK: [[CMP:%.+]] = icmp slt i32 [[ZERO]], 1000
// CHECK: br i1 [[CMP]], label %[[FOR_BODY:.+]], label %[[FOR_END:.+]]
// CHECK: [[FOR_BODY]]:
// CHECK: br label %[[FOR_INC:.+]]
// CHECK: [[FOR_INC]]:
// CHECK: [[ONE:%.+]] = load i32, i32* [[I]],
// CHECK: [[INC:%.+]] = add nsw i32 [[ONE]], 1
// CHECK: store i32 [[INC]], i32* [[I]],
// CHECK: br label %[[FOR_COND]],
// CHECK: [[FOR_END]]:
// CHECK: ret void
// CHECK: }
#endif