llvm-project/clang/test/OpenMP/default_firstprivate_ast_print.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

168 lines
5.0 KiB
C++
Raw Normal View History

// expected-no-diagnostics
[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-06 16:16:13 +05:30
//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
//RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
[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-06 16:16:13 +05:30
//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
//RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
[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-06 16:16:13 +05:30
//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
//RUN: -emit-pch -o %t %s
[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-06 16:16:13 +05:30
//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
//RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
[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-06 16:16:13 +05:30
//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
//RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
#ifndef HEADER
#define HEADER
struct SomeKernel {
int targetDev;
float devPtr;
SomeKernel();
~SomeKernel();
template <unsigned int nRHS>
void apply() {
#pragma omp parallel default(firstprivate)
{
Generate the capture for the field when the field is used in openmp region with implicit default inside the member function. This is to fix assert when field is referenced in OpenMP region with default (first|private) clause inside member function. The problem of assert is that the capture is not generated for the field. This patch is to generate capture when the field is used with implicit default, use it in the code, and save the capture off to make sure it is considered from that point and add first/private clauses. 1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to store generated capture fields info. 2> In function isOpenMPCaptureDecl: the caputer is generated and saved in ImplicitDefaultFirstprivateFDs. 3> Add new help functions: getImplicitFDCapExprDecl isImplicitDefaultFirstprivateFD addImplicitDefaultFirstprivateFD 4> Add addition argument in hasDSA to check default attribute for default(first|private). 5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to build the implicit clause. 6> Add new parameter "Context" for buildCaptureDecl, due to when capture field, the parent context is needed to be used. 7> Change in isOpenMPPrivateDecl where stop propagate the capture from the enclosing region for private variable. 8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info to generate first|private clause. 9> Add new function isOpenMPRebuildMemberExpr: use to determine if field needs to be rebuild during template instantiation. Differential Revision: https://reviews.llvm.org/D127803
2022-06-14 10:11:10 -07:00
[=]() -> int {
return targetDev++;
}();
}
// PRINT: #pragma omp parallel default(firstprivate)
// PRINT-NEXT: {
Generate the capture for the field when the field is used in openmp region with implicit default inside the member function. This is to fix assert when field is referenced in OpenMP region with default (first|private) clause inside member function. The problem of assert is that the capture is not generated for the field. This patch is to generate capture when the field is used with implicit default, use it in the code, and save the capture off to make sure it is considered from that point and add first/private clauses. 1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to store generated capture fields info. 2> In function isOpenMPCaptureDecl: the caputer is generated and saved in ImplicitDefaultFirstprivateFDs. 3> Add new help functions: getImplicitFDCapExprDecl isImplicitDefaultFirstprivateFD addImplicitDefaultFirstprivateFD 4> Add addition argument in hasDSA to check default attribute for default(first|private). 5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to build the implicit clause. 6> Add new parameter "Context" for buildCaptureDecl, due to when capture field, the parent context is needed to be used. 7> Change in isOpenMPPrivateDecl where stop propagate the capture from the enclosing region for private variable. 8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info to generate first|private clause. 9> Add new function isOpenMPRebuildMemberExpr: use to determine if field needs to be rebuild during template instantiation. Differential Revision: https://reviews.llvm.org/D127803
2022-06-14 10:11:10 -07:00
// PRINT-NEXT: [=]() -> int {
// PRINT-NEXT: return this->targetDev++;
// PRINT-NEXT: }();
// PRINT-NEXT: }
// DUMP: -OMPParallelDirective
Generate the capture for the field when the field is used in openmp region with implicit default inside the member function. This is to fix assert when field is referenced in OpenMP region with default (first|private) clause inside member function. The problem of assert is that the capture is not generated for the field. This patch is to generate capture when the field is used with implicit default, use it in the code, and save the capture off to make sure it is considered from that point and add first/private clauses. 1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to store generated capture fields info. 2> In function isOpenMPCaptureDecl: the caputer is generated and saved in ImplicitDefaultFirstprivateFDs. 3> Add new help functions: getImplicitFDCapExprDecl isImplicitDefaultFirstprivateFD addImplicitDefaultFirstprivateFD 4> Add addition argument in hasDSA to check default attribute for default(first|private). 5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to build the implicit clause. 6> Add new parameter "Context" for buildCaptureDecl, due to when capture field, the parent context is needed to be used. 7> Change in isOpenMPPrivateDecl where stop propagate the capture from the enclosing region for private variable. 8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info to generate first|private clause. 9> Add new function isOpenMPRebuildMemberExpr: use to determine if field needs to be rebuild during template instantiation. Differential Revision: https://reviews.llvm.org/D127803
2022-06-14 10:11:10 -07:00
// DUMP-NEXT: -OMPDefaultClause
// DUMP-NOT: -OMPFirstprivateClause
}
// PRINT: template<> void apply<32U>()
// PRINT: #pragma omp parallel default(firstprivate)
// PRINT-NEXT: {
Generate the capture for the field when the field is used in openmp region with implicit default inside the member function. This is to fix assert when field is referenced in OpenMP region with default (first|private) clause inside member function. The problem of assert is that the capture is not generated for the field. This patch is to generate capture when the field is used with implicit default, use it in the code, and save the capture off to make sure it is considered from that point and add first/private clauses. 1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to store generated capture fields info. 2> In function isOpenMPCaptureDecl: the caputer is generated and saved in ImplicitDefaultFirstprivateFDs. 3> Add new help functions: getImplicitFDCapExprDecl isImplicitDefaultFirstprivateFD addImplicitDefaultFirstprivateFD 4> Add addition argument in hasDSA to check default attribute for default(first|private). 5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to build the implicit clause. 6> Add new parameter "Context" for buildCaptureDecl, due to when capture field, the parent context is needed to be used. 7> Change in isOpenMPPrivateDecl where stop propagate the capture from the enclosing region for private variable. 8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info to generate first|private clause. 9> Add new function isOpenMPRebuildMemberExpr: use to determine if field needs to be rebuild during template instantiation. Differential Revision: https://reviews.llvm.org/D127803
2022-06-14 10:11:10 -07:00
// PRINT-NEXT: [=]() -> int {
// PRINT-NEXT: return this->targetDev++;
// PRINT-NEXT: }();
// CHECK-NEXT: }
// DUMP: -OMPParallelDirective
// DUMP-NEXT: -OMPDefaultClause
Generate the capture for the field when the field is used in openmp region with implicit default inside the member function. This is to fix assert when field is referenced in OpenMP region with default (first|private) clause inside member function. The problem of assert is that the capture is not generated for the field. This patch is to generate capture when the field is used with implicit default, use it in the code, and save the capture off to make sure it is considered from that point and add first/private clauses. 1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to store generated capture fields info. 2> In function isOpenMPCaptureDecl: the caputer is generated and saved in ImplicitDefaultFirstprivateFDs. 3> Add new help functions: getImplicitFDCapExprDecl isImplicitDefaultFirstprivateFD addImplicitDefaultFirstprivateFD 4> Add addition argument in hasDSA to check default attribute for default(first|private). 5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to build the implicit clause. 6> Add new parameter "Context" for buildCaptureDecl, due to when capture field, the parent context is needed to be used. 7> Change in isOpenMPPrivateDecl where stop propagate the capture from the enclosing region for private variable. 8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info to generate first|private clause. 9> Add new function isOpenMPRebuildMemberExpr: use to determine if field needs to be rebuild during template instantiation. Differential Revision: https://reviews.llvm.org/D127803
2022-06-14 10:11:10 -07:00
// DUMP-NEXT: -OMPFirstprivateClause
// DUMP-NEXT: -DeclRefExpr {{.*}} 'targetDev'
};
void use_template() {
SomeKernel aKern;
aKern.apply<32>();
}
void foo() {
int a;
#pragma omp parallel default(firstprivate)
a++;
// PRINT: #pragma omp parallel default(firstprivate)
// PRINT-NEXT: a++;
// DUMP: -OMPParallelDirective
// DUMP-NEXT: -OMPDefaultClause
// DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
// DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
}
struct St {
int a, b;
static int y;
St() : a(0), b(0) {}
~St() {}
};
int St::y = 0;
void bar() {
St a = St();
static int yy = 0;
#pragma omp parallel default(firstprivate)
{
a.a += 1;
a.b += 1;
a.y++;
yy++;
St::y++;
}
// PRINT: #pragma omp parallel default(firstprivate)
// DUMP: -OMPParallelDirective
// DUMP-NEXT: -OMPDefaultClause
// DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
// DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
// DUMP-NEXT: -DeclRefExpr {{.*}} 'yy'
// DUMP-NEXT: -DeclRefExpr {{.*}} 'y'
}
Generate the capture for the field when the field is used in openmp region with implicit default inside the member function. This is to fix assert when field is referenced in OpenMP region with default (first|private) clause inside member function. The problem of assert is that the capture is not generated for the field. This patch is to generate capture when the field is used with implicit default, use it in the code, and save the capture off to make sure it is considered from that point and add first/private clauses. 1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to store generated capture fields info. 2> In function isOpenMPCaptureDecl: the caputer is generated and saved in ImplicitDefaultFirstprivateFDs. 3> Add new help functions: getImplicitFDCapExprDecl isImplicitDefaultFirstprivateFD addImplicitDefaultFirstprivateFD 4> Add addition argument in hasDSA to check default attribute for default(first|private). 5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to build the implicit clause. 6> Add new parameter "Context" for buildCaptureDecl, due to when capture field, the parent context is needed to be used. 7> Change in isOpenMPPrivateDecl where stop propagate the capture from the enclosing region for private variable. 8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info to generate first|private clause. 9> Add new function isOpenMPRebuildMemberExpr: use to determine if field needs to be rebuild during template instantiation. Differential Revision: https://reviews.llvm.org/D127803
2022-06-14 10:11:10 -07:00
void zoo(int);
struct A {
int z;
int f;
A();
~A();
void foo() {
#pragma omp parallel firstprivate(z) default(firstprivate)
{
z++;
f++;
zoo(z + f);
f++;
}
}
// PRINT: #pragma omp parallel firstprivate(this->z) default(firstprivate)
// DUMP: -OMPParallelDirective
// DUMP-NEXT: -OMPFirstprivateClause
// DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
// DUMP-NEXT: -OMPDefaultClause
// DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
// DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
// DUMP: -CXXThisExpr {{.*}} 'A *' implicit this
// DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
// DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
void bar() {
#pragma omp parallel firstprivate(z) default(firstprivate)
{
#pragma omp parallel private(z) default(firstprivate)
{
z++;
f++;
zoo(z + f);
f++;
}
}
}
// PRINT: #pragma omp parallel firstprivate(this->z) default(firstprivate)
// PRINT: #pragma omp parallel private(this->z) default(firstprivate)
// DUMP: -OMPParallelDirective
// DUMP-NEXT: -OMPFirstprivateClause
// DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
// DUMP-NEXT: -OMPDefaultClause
// DUMP: -OMPParallelDirective
// DUMP-NEXT: -OMPPrivateClaus
// DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
// DUMP-NEXT: -OMPDefaultClause
// DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
// DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
// DUMP: -CXXThisExpr {{.*}} 'A *' implicit this
// DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
// DUMP: -MemberExpr {{.*}}
// DUMP-NEXT: -CXXThisExpr
// DUMP: -CXXThisExpr {{.*}} 'A *' implicit this
// DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
};
#endif // HEADER