llvm-project/clang/test/OpenMP/unroll_ast_print.cpp
Animesh Kumar 0c6f2f629c [OpenMP] Update the default version of OpenMP to 5.1
The default version of OpenMP is updated from 5.0 to 5.1 which means if -fopenmp is specified but -fopenmp-version is not specified with clang, the default version of OpenMP is taken to be 5.1.  After modifying the Frontend for that, various LIT tests were updated. This patch contains all such changes. At a high level, these are the patterns of changes observed in LIT tests -

  # RUN lines which mentioned `-fopenmp-version=50` need to kept only if the IR for version 5.0 and 5.1 are different. Otherwise only one RUN line with no version info(i.e. default version) needs to be there.

  # Test cases of this sort already had the RUN lines with respect to the older default version 5.0 and the version 5.1. Only swapping the version specification flag `-fopenmp-version` from newer version RUN line to older version RUN line is required.

  # Diagnostics: Remove the 5.0 version specific RUN lines if there was no difference in the Diagnostics messages with respect to the default 5.1.

  # Diagnostics: In case there was any difference in diagnostics messages between 5.0 and 5.1, mention version specific messages in tests.

  # If the test contained version specific ifdef's e.g. "#ifdef OMP5" but there were no RUN lines for any other version than 5.X, then bring the code guarded by ifdef's outside and remove the ifdef's.

  # Some tests had RUN lines for both 5.0 and 5.1 versions, but it is found that the IR for 5.0 is not different from the 5.1, therefore such RUN lines are redundant. So, such duplicated lines are removed.

  # To generate CHECK lines automatically, use the script llvm/utils/update_cc_test_checks.py

Reviewed By: saiislam, ABataev

Differential Revision: https://reviews.llvm.org/D129635

(cherry picked from commit 9dd2999907dc791136a75238a6000f69bf67cf4e)
2023-06-15 12:41:09 +05:30

150 lines
4.6 KiB
C++

// Check no warnings/errors
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fsyntax-only -verify %s
// expected-no-diagnostics
// Check AST and unparsing
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -ast-dump %s | FileCheck %s --check-prefix=DUMP
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -ast-print %s | FileCheck %s --check-prefix=PRINT --match-full-lines
// Check same results after serialization round-trip
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-pch -o %t %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT --match-full-lines
#ifndef HEADER
#define HEADER
// placeholder for loop body code.
void body(...);
// PRINT-LABEL: void func_unroll() {
// DUMP-LABEL: FunctionDecl {{.*}} func_unroll
void func_unroll() {
// PRINT: #pragma omp unroll
// DUMP: OMPUnrollDirective
#pragma omp unroll
// PRINT-NEXT: for (int i = 7; i < 17; i += 3)
// DUMP-NEXT: ForStmt
for (int i = 7; i < 17; i += 3)
// PRINT-NEXT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: void func_unroll_full() {
// DUMP-LABEL: FunctionDecl {{.*}} func_unroll_full
void func_unroll_full() {
// PRINT: #pragma omp unroll full
// DUMP: OMPUnrollDirective
// DUMP-NEXT: OMPFullClause
#pragma omp unroll full
// PRINT-NEXT: for (int i = 7; i < 17; i += 3)
// DUMP-NEXT: ForStmt
for (int i = 7; i < 17; i += 3)
// PRINT-NEXT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: void func_unroll_partial() {
// DUMP-LABEL: FunctionDecl {{.*}} func_unroll_partial
void func_unroll_partial() {
// PRINT: #pragma omp unroll partial
// DUMP: OMPUnrollDirective
// DUMP-NEXT: OMPPartialClause
// DUMP-NEXT: <<<NULL>>>
#pragma omp unroll partial
// PRINT-NEXT: for (int i = 7; i < 17; i += 3)
// DUMP-NEXT: ForStmt
for (int i = 7; i < 17; i += 3)
// PRINT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: void func_unroll_partial_factor() {
// DUMP-LABEL: FunctionDecl {{.*}} func_unroll_partial_factor
void func_unroll_partial_factor() {
// PRINT: #pragma omp unroll partial(4)
// DUMP: OMPUnrollDirective
// DUMP-NEXT: OMPPartialClause
// DUMP-NEXT: ConstantExpr
// DUMP-NEXT: value: Int 4
// DUMP-NEXT: IntegerLiteral {{.*}} 4
#pragma omp unroll partial(4)
// PRINT-NEXT: for (int i = 7; i < 17; i += 3)
// DUMP-NEXT: ForStmt
for (int i = 7; i < 17; i += 3)
// PRINT-NEXT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: void func_unroll_partial_factor_for() {
// DUMP-LABEL: FunctionDecl {{.*}} func_unroll_partial_factor_for
void func_unroll_partial_factor_for() {
// PRINT: #pragma omp for
// DUMP: OMPForDirective
#pragma omp for
// PRINT: #pragma omp unroll partial(2)
// DUMP: OMPUnrollDirective
// DUMP-NEXT: OMPPartialClause
#pragma omp unroll partial(2)
// PRINT-NEXT: for (int i = 7; i < 17; i += 3)
// DUMP: ForStmt
for (int i = 7; i < 17; i += 3)
// PRINT-NEXT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: template <typename T, T Start, T End, T Step, int Factor> void unroll_templated() {
// DUMP-LABEL: FunctionTemplateDecl {{.*}} unroll_templated
template<typename T, T Start, T End, T Step, int Factor>
void unroll_templated() {
// PRINT: #pragma omp unroll partial(Factor)
// DUMP: OMPUnrollDirective
// DUMP-NEXT: OMPPartialClause
// DUMP-NEXT: DeclRefExpr {{.*}} 'Factor' 'int'
#pragma omp unroll partial(Factor)
// PRINT-NEXT: for (T i = Start; i < End; i += Step)
// DUMP-NEXT: ForStmt
for (T i = Start; i < End; i += Step)
// PRINT-NEXT: body(i);
// DUMP: CallExpr
body(i);
}
void unroll_template() {
unroll_templated<int,0,1024,1,4>();
}
// PRINT-LABEL: template <int Factor> void unroll_templated_factor(int start, int stop, int step) {
// DUMP-LABEL: FunctionTemplateDecl {{.*}} unroll_templated_factor
template <int Factor>
void unroll_templated_factor(int start, int stop, int step) {
// PRINT: #pragma omp unroll partial(Factor)
// DUMP: OMPUnrollDirective
// DUMP-NEXT: OMPPartialClause
// DUMP-NEXT: DeclRefExpr {{.*}} 'Factor' 'int'
#pragma omp unroll partial(Factor)
// PRINT-NEXT: for (int i = start; i < stop; i += step)
// DUMP-NEXT: ForStmt
for (int i = start; i < stop; i += step)
// PRINT-NEXT: body(i);
// DUMP: CallExpr
body(i);
}
void unroll_template_factor() {
unroll_templated_factor<4>(0, 42, 2);
}
#endif