[clang] 7f57b64 - [OpenMP] Extend lit test for parallel for simd construct
Author: Animesh Kumar Date: 2022-09-13T17:07:11+05:30 New Revision: 7f57b646d1501fedb21cfe8e02d5ede243ac51b1 URL: https://github.com/llvm/llvm-project/commit/7f57b646d1501fedb21cfe8e02d5ede243ac51b1 DIFF: https://github.com/llvm/llvm-project/commit/7f57b646d1501fedb21cfe8e02d5ede243ac51b1.diff LOG: [OpenMP] Extend lit test for parallel for simd construct This construct is being tested for atomic operation based upon the test 5.0/parallel_for_simd/test_parallel_for_simd_atomic.c from the SOLLVE repo: https://github.com/SOLLVE/sollve_vv Differential Revision: https://reviews.llvm.org/D132643 Added: Modified: clang/test/OpenMP/parallel_for_simd_codegen.cpp Removed: diff --git a/clang/test/OpenMP/parallel_for_simd_codegen.cpp b/clang/test/OpenMP/parallel_for_simd_codegen.cpp index 9e8fa026e76e0..cbe51d42db4e1 100644 --- a/clang/test/OpenMP/parallel_for_simd_codegen.cpp +++ b/clang/test/OpenMP/parallel_for_simd_codegen.cpp @@ -3,20 +3,20 @@ // RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-version=45 -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG -// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=OMP50 --check-prefix=CHECK -// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s -// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -no-opaque-pointers -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_DEBUG +// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -DOMP5 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=OMP50 --check-prefix=CHECK +// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -DOMP5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s +// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -DOMP5 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 -fopenmp -DOMP5 -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG // RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s // RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fopenmp-version=45 -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s -// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s -// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s -// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s -// RUN: %clang_cc1 -no-opaque-pointers -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 %s +// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp-simd -DOMP5 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exc
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From b5de1dd29956ae99ce7990554c4886453b2988e7 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From 26d8d82a3070700dd327337d37c757eb1db6f2cc Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From b891329e49972c15941f2d15408ff32cfe3995f3 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd closed https://github.com/llvm/llvm-project/pull/82220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Handle unsupported inscan modifier for generic types (PR #79431)
https://github.com/animeshk-amd created https://github.com/llvm/llvm-project/pull/79431 The https://reviews.llvm.org/D79948 patch had implemented the `omp scan` directive. The scan computation happens when the `reduction` clause with the `inscan` modifier is used. The present implementation doesn't support the reduction variable and the input list item to be of generic type. This patch handles this edge case by throwing a diagnostic error message when the `inscan` modifier is used on template type variables. This fixes #67002: => [OpenMP][Clang] Scan Directive not supported for Generic types >From 259a0da5b208d5f23d29c76f8ad24214780181e5 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 22 Jan 2024 05:28:07 -0600 Subject: [PATCH] [OpenMP][Clang] Handle unsupported inscan modifier for generic types The https://reviews.llvm.org/D79948 patch had implemented the 'omp scan' directive. The scan computation happens when the 'reduction' clause with the 'inscan' modifier is used. The present implementation doesn't support the reduction variable and the input list item to be of generic type. This patch handles this edge case by throwing a diagnostic error message when the 'inscan' modifier is used on template type variables. This fixes #67002: => [OpenMP][Clang] Scan Directive not supported for Generic types --- .../clang/Basic/DiagnosticSemaKinds.td| 2 ++ clang/lib/Sema/SemaOpenMP.cpp | 7 + clang/test/OpenMP/scan_ast_print.cpp | 24 + clang/test/OpenMP/scan_messages.cpp | 26 +++ 4 files changed, 25 insertions(+), 34 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a1c32abb4dcd880..34efa9107a81ab8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -11254,6 +11254,8 @@ def err_omp_reduction_not_inclusive_exclusive : Error< def err_omp_wrong_inscan_reduction : Error< "'inscan' modifier can be used only in 'omp for', 'omp simd', 'omp for simd'," " 'omp parallel for', or 'omp parallel for simd' directive">; +def err_omp_inscan_reduction_on_template_type: Error < + "'inscan' modifier currently does not support generic data types">; def err_omp_inscan_reduction_expected : Error< "expected 'reduction' clause with the 'inscan' modifier">; def note_omp_previous_inscan_reduction : Note< diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 217fcb979deea20..b0353bf9b287789 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -19520,6 +19520,13 @@ static bool actOnOMPReductionKindClause( bool FirstIter = true; for (Expr *RefExpr : VarList) { assert(RefExpr && "nullptr expr in OpenMP reduction clause."); +if (ClauseKind == OMPC_reduction && +RD.RedModifier == OMPC_REDUCTION_inscan && RefExpr->isTypeDependent()) { + S.Diag(RefExpr->getExprLoc(), + diag::err_omp_inscan_reduction_on_template_type); + continue; +} + // OpenMP [2.1, C/C++] // A list item is a variable or array section, subject to the restrictions // specified in Section 2.4 on page 42 and in each of the sections diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4e..090f7d2cafc34f1 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -12,28 +12,6 @@ void foo() {} -template -T tmain(T argc) { - static T a; -#pragma omp for reduction(inscan, +: a) - for (int i = 0; i < 10; ++i) { -#pragma omp scan inclusive(a) - } - return a + argc; -} -// CHECK: static T a; -// CHECK-NEXT: #pragma omp for reduction(inscan, +: a) -// CHECK-NEXT: for (int i = 0; i < 10; ++i) { -// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} -// CHECK: static int a; -// CHECK-NEXT: #pragma omp for reduction(inscan, +: a) -// CHECK-NEXT: for (int i = 0; i < 10; ++i) { -// CHECK-NEXT: #pragma omp scan inclusive(a) -// CHECK: static char a; -// CHECK-NEXT: #pragma omp for reduction(inscan, +: a) -// CHECK-NEXT: for (int i = 0; i < 10; ++i) { -// CHECK-NEXT: #pragma omp scan inclusive(a) - int main(int argc, char **argv) { static int a; // CHECK: static int a; @@ -46,7 +24,7 @@ int main(int argc, char **argv) { // CHECK-NEXT: #pragma omp for simd reduction(inscan, ^: a,argc) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan exclusive(a,argc){{$}} - return tmain(argc) + tmain(argv[0][0]) + a; + return 0; } #endif diff --git a/clang/test/OpenMP/scan_messages.cpp b/clang/test/OpenMP/scan_messages.cpp index 0de94898c65712f..3e889072bebf79b 100644 --- a/clang/test/OpenMP/scan_messages.cpp +++ b/clang/test/OpenMP/scan_messages.cpp @@ -16,32 +16,32 @@ T tmain() { #pragma omp scan untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#
[clang] [OpenMP][Clang] Handle unsupported inscan modifier for generic types (PR #79431)
@@ -12,28 +12,6 @@ void foo() {} -template animeshk-amd wrote: The test was passing because the `for` directive at line:18 is used outside a parallel region, in which case the compiler wasn't crashing. Contrary to what would happen when used within a parallel region. Since the `scan` directive currently doesn't support templates, within or without a parallel region, I transferred this test to the scan_messages.cpp line:87 with expected errors. https://github.com/llvm/llvm-project/pull/79431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Handle unsupported inscan modifier for generic types (PR #79431)
@@ -19520,6 +19520,13 @@ static bool actOnOMPReductionKindClause( bool FirstIter = true; for (Expr *RefExpr : VarList) { assert(RefExpr && "nullptr expr in OpenMP reduction clause."); +if (ClauseKind == OMPC_reduction && +RD.RedModifier == OMPC_REDUCTION_inscan && RefExpr->isTypeDependent()) { + S.Diag(RefExpr->getExprLoc(), + diag::err_omp_inscan_reduction_on_template_type); + continue; +} + animeshk-amd wrote: It should ideally be supported. However, the compiler crashes as per #67002 on the latest builds. https://github.com/llvm/llvm-project/pull/79431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Handle unsupported inscan modifier for generic types (PR #79431)
https://github.com/animeshk-amd edited https://github.com/llvm/llvm-project/pull/79431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 06da9b9 - [OpenMP] Extend the lit test for uses_allocators in target region
Author: Animesh Kumar Date: 2022-10-14T19:12:33+05:30 New Revision: 06da9b94ae374f81a0898b01608c1c3529dfa29a URL: https://github.com/llvm/llvm-project/commit/06da9b94ae374f81a0898b01608c1c3529dfa29a DIFF: https://github.com/llvm/llvm-project/commit/06da9b94ae374f81a0898b01608c1c3529dfa29a.diff LOG: [OpenMP] Extend the lit test for uses_allocators in target region This patch improves the LIT tests on the following : 1. The test on `uses_allocators` clause in the `target` region by adding the respective CHECK lines. Allocator `omp_thread_mem_alloc` is also added in the test. 2. The `defaultmap` clause wasn't being tested for the variable- category `scalar` and the implicit-behavior `tofrom` with respect to the OpenMP default version. These improvements are inspired from SOLLVE tests. SOLLVE repo: https://github.com/SOLLVE/sollve_vv Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D132855 Added: Modified: clang/test/OpenMP/target_map_codegen_10.cpp clang/test/OpenMP/target_uses_allocators.c Removed: diff --git a/clang/test/OpenMP/target_map_codegen_10.cpp b/clang/test/OpenMP/target_map_codegen_10.cpp index e6fa9fe1825b7..f5201ec8305c9 100644 --- a/clang/test/OpenMP/target_map_codegen_10.cpp +++ b/clang/test/OpenMP/target_map_codegen_10.cpp @@ -3,12 +3,20 @@ #define HEADER ///==/// -// RUN: %clang_cc1 -DCK11 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix CK11 + +// RUN: %clang_cc1 -DCK11 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes CK11,CK11_4 // RUN: %clang_cc1 -DCK11 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix CK11 -// RUN: %clang_cc1 -DCK11 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix CK11 +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes CK11,CK11_4 +// RUN: %clang_cc1 -DCK11 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes CK11,CK11_4 // RUN: %clang_cc1 -DCK11 -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix CK11 +// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes CK11,CK11_4 + +// RUN: %clang_cc1 -DCK11 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes CK11,CK11_5 +// RUN: %clang_cc1 -DCK11 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes CK11,CK11_5 +// RUN: %clang_cc1 -DCK11 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes CK11,CK11_5 +// RUN: %clang_cc1 -DCK11 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
[clang] 0f8e7b4 - [OpenMP] Add map clause to the LIT test on use_device_addr clause
Author: Animesh Kumar Date: 2022-11-09T12:23:39+05:30 New Revision: 0f8e7b43291ce5881cde6f3d34041c578390dda4 URL: https://github.com/llvm/llvm-project/commit/0f8e7b43291ce5881cde6f3d34041c578390dda4 DIFF: https://github.com/llvm/llvm-project/commit/0f8e7b43291ce5881cde6f3d34041c578390dda4.diff LOG: [OpenMP] Add map clause to the LIT test on use_device_addr clause As per the OpenMP Spec, "A list item in a use_device_addr clause must have a corresponding list item in the device data environment" . Therefore a `map` clause is added which will make sure that the respective list items are mapped to the device data environment before the `use_device_addr` clause is specified. The CHECK lines are also modified based on this change. Differential Revision: https://reviews.llvm.org/D134974 Added: Modified: clang/test/OpenMP/target_data_use_device_addr_codegen.cpp Removed: diff --git a/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp b/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp index 5522dcbb54ce5..0b9bc0959f3f4 100644 --- a/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp +++ b/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp @@ -11,13 +11,13 @@ #ifndef HEADER #define HEADER -// CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [5 x i64] zeroinitializer +// CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [6 x i64] [i64 4, i64 16, i64 4, i64 4, i64 0, i64 4] // 64 = 0x40 = OMP_MAP_RETURN_PARAM -// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [5 x i64] [i64 64, i64 64, i64 64, i64 64, i64 64] -// CHECK-DAG: [[SIZES2:@.+]] = private unnamed_addr constant [5 x i64] zeroinitializer +// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [6 x i64] [i64 67, i64 67, i64 3, i64 67, i64 67, i64 67] +// CHECK-DAG: [[SIZES2:@.+]] = private unnamed_addr constant [6 x i64] [i64 0, i64 4, i64 16, i64 4, i64 4, i64 0] // 0 = OMP_MAP_NONE // 281474976710720 = 0x10040 = OMP_MAP_MEMBER_OF | OMP_MAP_RETURN_PARAM -// CHECK-DAG: [[MAPTYPES2:@.+]] = private unnamed_addr constant [5 x i64] [i64 0, i64 281474976710720, i64 281474976710720, i64 281474976710720, i64 281474976710720] +// CHECK-DAG: [[MAPTYPES2:@.+]] = private unnamed_addr constant [6 x i64] [i64 0, i64 281474976710723, i64 281474976710739, i64 281474976710739, i64 281474976710675, i64 281474976710723] struct S { int a = 0; int *ptr = &a; @@ -25,7 +25,7 @@ struct S { int arr[4]; S() {} void foo() { -#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:a]) +#pragma omp target data map(tofrom: a, ptr [3:4], ref, ptr[0], arr[:a]) use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:a]) ++a, ++*ptr, ++ref, ++arr[0]; } }; @@ -38,7 +38,7 @@ int main() { float vla[(int)a]; S s; s.foo(); -#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:(int)a], vla[0]) +#pragma omp target data map(tofrom: a, ptr [3:4], ref, ptr[0], arr[:(int)a], vla[0]) use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:(int)a], vla[0]) ++a, ++*ptr, ++ref, ++arr[0], ++vla[0]; return a; } @@ -48,47 +48,68 @@ int main() { // CHECK: [[PTR_ADDR:%.+]] = alloca ptr, // CHECK: [[REF_ADDR:%.+]] = alloca ptr, // CHECK: [[ARR_ADDR:%.+]] = alloca [4 x float], -// CHECK: [[BPTRS:%.+]] = alloca [5 x ptr], -// CHECK: [[PTRS:%.+]] = alloca [5 x ptr], +// CHECK: [[BPTRS:%.+]] = alloca [6 x ptr], +// CHECK: [[PTRS:%.+]] = alloca [6 x ptr], +// CHECK: [[MAP_PTRS:%.+]] = alloca [6 x ptr], +// CHECK: [[SIZES:%.+]] = alloca [6 x i64], // CHECK: [[VLA_ADDR:%.+]] = alloca float, i64 %{{.+}}, // CHECK: [[PTR:%.+]] = load ptr, ptr [[PTR_ADDR]], -// CHECK: [[REF:%.+]] = load ptr, ptr [[REF_ADDR]], -// CHECK: [[ARR:%.+]] = getelementptr inbounds [4 x float], ptr [[ARR_ADDR]], i64 0, i64 0 -// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [5 x ptr], ptr [[BPTRS]], i32 0, i32 0 +// CHECK-NEXT: [[P4:%.+]] = load ptr, ptr [[PTR_ADDR]], align 8 +// CHECK-NEXT: [[ARR_IDX:%.+]] = getelementptr inbounds float, ptr [[P4]], i64 3 +// CHECK: [[P5:%.+]] = load ptr, ptr [[PTR_ADDR]], align 8 +// CHECK-NEXT: [[P6:%.+]] = load ptr, ptr [[PTR_ADDR]], align 8 +// CHECK-NEXT: [[ARR_IDX1:%.+]] = getelementptr inbounds float, ptr [[P6]], i64 0 +// CHECK: [[P7:%.+]] = load ptr, ptr [[REF_ADDR]], +// CHECK-NEXT: [[REF:%.+]] = load ptr, ptr [[REF_ADDR]], +// CHECK-NEXT: [[ARR_IDX2:%.+]] = getelementptr inbounds [4 x float], ptr [[ARR_ADDR]], i64 0, i64 0 +// CHECK: [[P10:%.+]] = mul nuw i64 {{.+}}, 4 +// CHECK-NEXT: [[ARR_IDX5:%.+]] = getelementptr inbounds float, ptr [[VLA_ADDR]], i64 0 +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[SIZES]], ptr align 8 [[SIZES1]], i64 48, i1 false) +// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [6 x ptr], ptr [[BPTRS]], i32 0, i32 0 // CHECK: store ptr [[A_ADDR]], ptr [[BPTR0]], -// CHECK: [[PTR0:%.+]] =
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd created https://github.com/llvm/llvm-project/pull/82220 This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. Grateful to @alexey-bataev for suggesting these changes. >From 92ce8475d7c5b30d1c46f11cb85707b6e7d70f71 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Handle unsupported inscan modifier for generic types (PR #79431)
https://github.com/animeshk-amd closed https://github.com/llvm/llvm-project/pull/79431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Handle unsupported inscan modifier for generic types (PR #79431)
animeshk-amd wrote: Closing this PR because https://github.com/llvm/llvm-project/pull/82220 is fixing the issue #67002 https://github.com/llvm/llvm-project/pull/79431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
animeshk-amd wrote: The older PR didn't need to be merged. I've closed that one. This PR is independent. https://github.com/llvm/llvm-project/pull/82220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From 92ce8475d7c5b30d1c46f11cb85707b6e7d70f71 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From d1bc5c5fa48b58fd50d28f69051353afef7bf496 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
animeshk-amd wrote: Added a LIT test for the same. https://github.com/llvm/llvm-project/pull/82220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From 1b010100d6da3a17a58f82f6094b23e51de2c008 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From 53a7d681198006460a6e2b38d1a89146b3d26b03 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From ccf9823e7349435af2311a1ea15b4457ecb65107 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][Clang] Enable inscan modifier for generic datatypes (PR #82220)
https://github.com/animeshk-amd updated https://github.com/llvm/llvm-project/pull/82220 >From b5de1dd29956ae99ce7990554c4886453b2988e7 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Mon, 19 Feb 2024 00:28:39 -0600 Subject: [PATCH] [OpenMP][Clang] Enable inscan modifier for generic datatypes This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. --- clang/lib/Sema/SemaOpenMP.cpp| 3 ++- clang/test/OpenMP/scan_ast_print.cpp | 18 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7f75cfc5b54f35..f4364a259ad57f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4962,7 +4962,8 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, if (RC->getModifier() != OMPC_REDUCTION_inscan) continue; for (Expr *E : RC->copy_array_temps()) -MarkDeclarationsReferencedInExpr(E); +if (E) + MarkDeclarationsReferencedInExpr(E); } if (auto *AC = dyn_cast(C)) { for (Expr *E : AC->varlists()) diff --git a/clang/test/OpenMP/scan_ast_print.cpp b/clang/test/OpenMP/scan_ast_print.cpp index 3bbd3b60c3e8c4..82cb13eb6e70f7 100644 --- a/clang/test/OpenMP/scan_ast_print.cpp +++ b/clang/test/OpenMP/scan_ast_print.cpp @@ -17,6 +17,10 @@ T tmain(T argc) { static T a; #pragma omp for reduction(inscan, +: a) for (int i = 0; i < 10; ++i) { +#pragma omp scan inclusive(a) + } +#pragma omp parallel for reduction(inscan, +:a) + for (int i = 0; i < 10; ++i) { #pragma omp scan inclusive(a) } return a + argc; @@ -25,15 +29,29 @@ T tmain(T argc) { // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a){{$}} + // CHECK: static int a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) + +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + // CHECK: static char a; // CHECK-NEXT: #pragma omp for reduction(inscan, +: a) // CHECK-NEXT: for (int i = 0; i < 10; ++i) { // CHECK-NEXT: #pragma omp scan inclusive(a) +// CHECK: #pragma omp parallel for reduction(inscan, +: a) +// CHECK-NEXT: for (int i = 0; i < 10; ++i) { +// CHECK-NEXT: #pragma omp scan inclusive(a) + int main(int argc, char **argv) { static int a; // CHECK: static int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits