[clang] [llvm] [OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier (PR #145490)
https://github.com/ro-i closed https://github.com/llvm/llvm-project/pull/145490 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier (PR #145490)
ro-i wrote: merged, thanls for the review! https://github.com/llvm/llvm-project/pull/145490 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][clang] declare mapper: fix handling of nested types (PR #143504)
https://github.com/ro-i closed https://github.com/llvm/llvm-project/pull/143504 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][clang] declare mapper: fix handling of nested types (PR #143504)
ro-i wrote: Merged. Thanks for the review :) https://github.com/llvm/llvm-project/pull/143504 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier (PR #145490)
https://github.com/ro-i created https://github.com/llvm/llvm-project/pull/145490 Implement parsing and semantic analysis support for the optional 'strict' modifier of the num_threads clause. This modifier has been introduced in OpenMP 6.0, section 12.1.2. Note: this is basically 1:1 https://reviews.llvm.org/D138328. >From 95f4b7abc6780c8b55ded2c3b09c382ca5270a8f Mon Sep 17 00:00:00 2001 From: Robert Imschweiler Date: Tue, 24 Jun 2025 04:46:29 -0500 Subject: [PATCH] [OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier Implement parsing and semantic analysis support for the optional 'strict' modifier of the num_threads clause. This modifier has been introduced in OpenMP 6.0, section 12.1.2. --- clang/include/clang/AST/OpenMPClause.h| 29 ++- clang/include/clang/Basic/OpenMPKinds.def | 7 ++ clang/include/clang/Basic/OpenMPKinds.h | 6 ++ clang/include/clang/Sema/SemaOpenMP.h | 8 +- clang/lib/AST/OpenMPClause.cpp| 5 ++ clang/lib/Basic/OpenMPKinds.cpp | 21 - clang/lib/Parse/ParseOpenMP.cpp | 33 +++- clang/lib/Sema/SemaOpenMP.cpp | 76 +++ clang/lib/Sema/TreeTransform.h| 11 ++- clang/lib/Serialization/ASTReader.cpp | 2 + clang/lib/Serialization/ASTWriter.cpp | 2 + clang/test/OpenMP/parallel_ast_print.cpp | 42 +- .../OpenMP/parallel_num_threads_messages.cpp | 73 +- llvm/include/llvm/Frontend/OpenMP/OMP.td | 7 ++ 14 files changed, 272 insertions(+), 50 deletions(-) diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index 05239668b34b1..c6f99fb21a0f0 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -824,31 +824,52 @@ class OMPNumThreadsClause final public OMPClauseWithPreInit { friend class OMPClauseReader; + /// Modifiers for 'num_threads' clause. + OpenMPNumThreadsClauseModifier Modifier = OMPC_NUMTHREADS_unknown; + + /// Location of the modifier. + SourceLocation ModifierLoc; + + /// Sets modifier. + void setModifier(OpenMPNumThreadsClauseModifier M) { Modifier = M; } + + /// Sets modifier location. + void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; } + /// Set condition. void setNumThreads(Expr *NThreads) { setStmt(NThreads); } public: /// Build 'num_threads' clause with condition \a NumThreads. /// + /// \param Modifier Clause modifier. /// \param NumThreads Number of threads for the construct. /// \param HelperNumThreads Helper Number of threads for the construct. /// \param CaptureRegion Innermost OpenMP region where expressions in this /// clause must be captured. /// \param StartLoc Starting location of the clause. /// \param LParenLoc Location of '('. + /// \param ModifierLoc Modifier location. /// \param EndLoc Ending location of the clause. - OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads, - OpenMPDirectiveKind CaptureRegion, + OMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, + Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc) + SourceLocation ModifierLoc, SourceLocation EndLoc) : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc), -OMPClauseWithPreInit(this) { +OMPClauseWithPreInit(this), Modifier(Modifier), +ModifierLoc(ModifierLoc) { setPreInitStmt(HelperNumThreads, CaptureRegion); } /// Build an empty clause. OMPNumThreadsClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {} + /// Gets modifier. + OpenMPNumThreadsClauseModifier getModifier() const { return Modifier; } + + /// Gets modifier location. + SourceLocation getModifierLoc() const { return ModifierLoc; } + /// Returns number of threads. Expr *getNumThreads() const { return getStmtAs(); } }; diff --git a/clang/include/clang/Basic/OpenMPKinds.def b/clang/include/clang/Basic/OpenMPKinds.def index 2b1dc1e0121b2..9d6f816eea91f 100644 --- a/clang/include/clang/Basic/OpenMPKinds.def +++ b/clang/include/clang/Basic/OpenMPKinds.def @@ -86,6 +86,9 @@ #ifndef OPENMP_NUMTASKS_MODIFIER #define OPENMP_NUMTASKS_MODIFIER(Name) #endif +#ifndef OPENMP_NUMTHREADS_MODIFIER +#define OPENMP_NUMTHREADS_MODIFIER(Name) +#endif #ifndef OPENMP_DOACROSS_MODIFIER #define OPENMP_DOACROSS_MODIFIER(Name) #endif @@ -227,6 +230,9 @@ OPENMP_GRAINSIZE_MODIFIER(strict) // Modifiers for the 'num_tasks' clause. OPENMP_NUMTASKS_MODIFIER(strict) +// Modifiers for the 'num_tasks' clause. +OPENMP_NUMTHREADS_MODIFIER(strict) + // Modifiers for 'allocate' clause. OPENMP_ALLOCATE_MODIFIER(allocator) OPENMP_ALLOCATE_MODIFIER(align) @@ -238,6 +244,7 @@ OPENMP_DOACROSS_MODIFIER(sink_omp
[clang] [OpenMP] Fix comma -> semicolon (PR #145900)
https://github.com/ro-i created https://github.com/llvm/llvm-project/pull/145900 Fix small typo. >From 935946e76a4a6728acc486f2c419f21256a55cc1 Mon Sep 17 00:00:00 2001 From: Robert Imschweiler Date: Thu, 26 Jun 2025 09:10:38 -0500 Subject: [PATCH] [OpenMP] Fix comma -> semicolon Fix small typo. --- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index 2bc9cd549f01f..e25b6948d30f8 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -1257,9 +1257,9 @@ void CGOpenMPRuntimeGPU::emitParallelCall(CodeGenFunction &CGF, if (!NumThreadsVal) NumThreadsVal = llvm::ConstantInt::get(CGF.Int32Ty, -1); else - NumThreadsVal = Bld.CreateZExtOrTrunc(NumThreadsVal, CGF.Int32Ty), + NumThreadsVal = Bld.CreateZExtOrTrunc(NumThreadsVal, CGF.Int32Ty); - assert(IfCondVal && "Expected a value"); +assert(IfCondVal && "Expected a value"); llvm::Value *RTLoc = emitUpdateLocation(CGF, Loc); llvm::Value *Args[] = { RTLoc, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP][clang] declare mapper: fix handling of nested types (PR #143504)
ro-i wrote: As far as I can see the test failures (TypeSanitizer-x86_64) are unrelated to this PR. https://github.com/llvm/llvm-project/pull/143504 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Fix comma -> semicolon (PR #145900)
ro-i wrote: > Unresolved Tests (1): > lldb-api :: tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py Tests being flaky again I guess https://github.com/llvm/llvm-project/pull/145900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Fix comma -> semicolon (PR #145900)
https://github.com/ro-i closed https://github.com/llvm/llvm-project/pull/145900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP][clang] 6.0: parsing/sema for message/severity for parallel (PR #146093)
https://github.com/ro-i created https://github.com/llvm/llvm-project/pull/146093 Implement parsing and semantic analysis support for the message and severity clauses that have been added to the parallel directive in OpenMP 6.0, 12.1. >From b01bdf107f80f0f023270326e4a16b1dcadd69d8 Mon Sep 17 00:00:00 2001 From: Robert Imschweiler Date: Fri, 27 Jun 2025 10:07:01 -0500 Subject: [PATCH] [OpenMP][clang] 6.0: parsing/sema for message/severity for parallel Implement parsing and semantic analysis support for the message and severity clauses that have been added to the parallel directive in OpenMP 6.0, 12.1. --- clang/include/clang/AST/OpenMPClause.h| 6 +- clang/lib/Sema/SemaOpenMP.cpp | 4 +- clang/test/OpenMP/parallel_ast_print.cpp | 24 ++--- .../test/OpenMP/parallel_message_messages.cpp | 89 +++ .../OpenMP/parallel_severity_messages.cpp | 70 +++ llvm/include/llvm/Frontend/OpenMP/OMP.td | 2 + 6 files changed, 179 insertions(+), 16 deletions(-) create mode 100644 clang/test/OpenMP/parallel_message_messages.cpp create mode 100644 clang/test/OpenMP/parallel_severity_messages.cpp diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index c6f99fb21a0f0..8b602f49aefde 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -1775,7 +1775,8 @@ class OMPAtClause final : public OMPClause { } }; -/// This represents 'severity' clause in the '#pragma omp error' directive +/// This represents the 'severity' clause in the '#pragma omp error' and the +/// '#pragma omp parallel' directives. /// /// \code /// #pragma omp error severity(fatal) @@ -1855,7 +1856,8 @@ class OMPSeverityClause final : public OMPClause { } }; -/// This represents 'message' clause in the '#pragma omp error' directive +/// This represents the 'message' clause in the '#pragma omp error' and the +/// '#pragma omp parallel' directives. /// /// \code /// #pragma omp error message("GNU compiler required.") diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index a30acbe9a4bca..4ecc9b0d4c5c8 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -6620,6 +6620,8 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective( case OMPC_affinity: case OMPC_bind: case OMPC_filter: + case OMPC_severity: + case OMPC_message: continue; case OMPC_allocator: case OMPC_flush: @@ -6637,8 +6639,6 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective( case OMPC_match: case OMPC_when: case OMPC_at: - case OMPC_severity: - case OMPC_message: default: llvm_unreachable("Unexpected clause"); } diff --git a/clang/test/OpenMP/parallel_ast_print.cpp b/clang/test/OpenMP/parallel_ast_print.cpp index 948baaff30d89..15439ea31215a 100644 --- a/clang/test/OpenMP/parallel_ast_print.cpp +++ b/clang/test/OpenMP/parallel_ast_print.cpp @@ -173,13 +173,13 @@ T tmain(T argc, T *argv) { foo(); #endif #ifdef OMP60 -#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(strict: C) copyin(S::TS, thrp) proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10]) +#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(strict: C) copyin(S::TS, thrp) proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10]) message("msg") severity(fatal) foo(); #endif #pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc) foo(); #ifdef OMP60 -#pragma omp parallel if (C) num_threads(strict: s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc) +#pragma omp parallel if (C) num_threads(strict: s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc) message("msg") severity(warning) foo(); #endif return 0; @@ -196,11 +196,11 @@ T tmain(T argc, T *argv) { // CHECK-NEXT: foo() // OMP51-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) // OMP51-NEXT: foo() -// OMP60-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(strict: C) copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) +// OMP60-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(strict: C) copyin(S::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) message("