[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2023-11-16 Thread David Pagan via cfe-commits


@@ -7485,6 +7485,99 @@ void 
CodeGenModule::printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
   }
 }
 
+namespace {
+/// A 'teams loop' with a nested 'loop bind(parallel)' or generic function
+/// call in the associated loop-nest cannot be a 'parllel for'.
+class TeamsLoopChecker final : public ConstStmtVisitor {

ddpagan wrote:

Alexey - thanks for the review comments. Good suggestion here. I'll look at 
moving the analysis.

https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [mlir] [clang] [compiler-rt] [clang-tools-extra] [llvm] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-20 Thread David Pagan via cfe-commits

https://github.com/ddpagan commented:

Aside from Alexey's comments, LGTM.

https://github.com/llvm/llvm-project/pull/75709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-01-01 Thread David Pagan via cfe-commits

ddpagan wrote:

Ping.

https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-01-10 Thread David Pagan via cfe-commits


@@ -6106,6 +6106,8 @@ class OMPTeamsGenericLoopDirective final : public 
OMPLoopDirective {
 class OMPTargetTeamsGenericLoopDirective final : public OMPLoopDirective {
   friend class ASTStmtReader;
   friend class OMPExecutableDirective;
+  /// true if loop directive's associated loop can be a parallel for.
+  bool CanBeParallelFor = false;

ddpagan wrote:

Hi Alexey - thanks for the comment.  A clarification, as I'm not sure exactly 
what you're referring to.

So currently, when OMPTargetTeamsGenericLoopDirective is created in 
SemaOpenMP.cpp, teamsLoopCanBeParallelFor(AStmt) is called as an argument to 
the create, the result of which is stored in CanBeParallelFor. Later, when the 
directive is seen in CodeGen/CGStmtOpenMP.cpp, the boolean CanBeParallelFor 
(via the function canBeParallelFor()) is checked to determine how to emit the 
directive (parallel or distribute).

Are you saying that instead of checking whether the loop can be parallel while 
we're in Sema, and saving that value when we create the target teams loop 
directive, that we should determine this through a call to the Sema function 
teamsLoopCanBeParallelFor() while in CodeGen?



https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-01-10 Thread David Pagan via cfe-commits


@@ -6106,6 +6106,8 @@ class OMPTeamsGenericLoopDirective final : public 
OMPLoopDirective {
 class OMPTargetTeamsGenericLoopDirective final : public OMPLoopDirective {
   friend class ASTStmtReader;
   friend class OMPExecutableDirective;
+  /// true if loop directive's associated loop can be a parallel for.
+  bool CanBeParallelFor = false;

ddpagan wrote:

Ok. Thanks, Alexey.

https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-03-14 Thread David Pagan via cfe-commits


@@ -11311,6 +11311,10 @@ class Sema final {
 OpenMPDirectiveKind &Kind,
 OpenMPDirectiveKind &PrevMappedDirective);
 
+  /// [target] teams loop is equivalent to parallel for if associated loop
+  /// nest meets certain critera.
+  bool teamsLoopCanBeParallelFor(Stmt *Astmt);
+

ddpagan wrote:

> Do you really need to expose it in Sema or you can make it just a static 
> local function in SemaOpenMP.cpp?

Actually, no. Thanks for noticing that. I'll make the change.

https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-03-14 Thread David Pagan via cfe-commits


@@ -1537,6 +1537,12 @@ class CodeGenModule : public CodeGenTypeCache {
   void printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
const Decl *D) const;
 
+  /// Under debug mode, print status of target teams loop transformation,
+  /// which should be either '#distribute' or '#parallel for'
+  void emitTargetTeamsLoopCodegenStatus(std::string StatusMsg,
+const OMPExecutableDirective &D,
+bool IsDevice);
+

ddpagan wrote:

> Don't like the idea of adding new member function specifically for debugging

Agreed. Changed it to a static local function.

https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-03-11 Thread David Pagan via cfe-commits

ddpagan wrote:

After some additional discussion with Alexey offline, he concluded that the 
current changes are okay, specifically for this reason:

_"Then I realized that actually it does not require AST nodes building. In this 
case, this helper class should be moved to CodeGenStmt and hidden in the 
anonymous namespace. But you also need to use it in CodeGenModule. In this case 
better to use a flag in statement, as you have it right now. I.e. having this 
analysis in Sema looks good_"


https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Fix target data if/logical expression assert fail (PR #70268)

2023-10-25 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/70268

Fixed assertion failure

  Basic Block in function 'main' does not have terminator!
  label %land.end

caused by premature setting of CodeGenIP upon entry to emitTargetDataCalls, 
where subsequent evaluation of logical expression created new basic blocks, 
leaving CodeGenIP pointing to the wrong basic block. CodeGenIP is now set near 
the end of the function, just prior to generating a comparison of the logical 
expression result (from the if clause) which uses CodeGenIP to insert new IR.

>From d027a1c75322c7158560630d382f8ab01726a728 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Tue, 24 Oct 2023 14:12:56 -0500
Subject: [PATCH] [clang][OpenMP] Fix target data if/logical expression assert
 fail

Fixed assertion failure

  Basic Block in function 'main' does not have terminator!
  label %land.end

caused by premature setting of CodeGenIP upon entry to
emitTargetDataCalls, where subsequent evaluation of logical
expression created new basic blocks, leaving CodeGenIP pointing to
the wrong basic block. CodeGenIP is now set near the end of the
function, just prior to generating a comparison of the logical
expression result (from the if clause) which uses CodeGenIP to
insert new IR.
---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp |  10 +-
 .../OpenMP/target_data_if_logical_codegen.cpp | 120 ++
 2 files changed, 125 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/OpenMP/target_data_if_logical_codegen.cpp

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index aae1a0ea250eea2..75fad160b716207 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10230,11 +10230,6 @@ void CGOpenMPRuntime::emitTargetDataCalls(
   PrePostActionTy NoPrivAction;
 
   using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-  InsertPointTy AllocaIP(CGF.AllocaInsertPt->getParent(),
- CGF.AllocaInsertPt->getIterator());
-  InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
-  CGF.Builder.GetInsertPoint());
-  llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
 
   llvm::Value *IfCondVal = nullptr;
   if (IfCond)
@@ -10314,6 +10309,11 @@ void CGOpenMPRuntime::emitTargetDataCalls(
   // Source location for the ident struct
   llvm::Value *RTLoc = emitUpdateLocation(CGF, D.getBeginLoc());
 
+  InsertPointTy AllocaIP(CGF.AllocaInsertPt->getParent(),
+ CGF.AllocaInsertPt->getIterator());
+  InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
+  CGF.Builder.GetInsertPoint());
+  llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
   CGF.Builder.restoreIP(OMPBuilder.createTargetData(
   OmpLoc, AllocaIP, CodeGenIP, DeviceID, IfCondVal, Info, GenMapInfoCB,
   /*MapperFunc=*/nullptr, BodyCB, DeviceAddrCB, CustomMapperCB, RTLoc));
diff --git a/clang/test/OpenMP/target_data_if_logical_codegen.cpp 
b/clang/test/OpenMP/target_data_if_logical_codegen.cpp
new file mode 100644
index 000..85d98b0c3bcd4d8
--- /dev/null
+++ b/clang/test/OpenMP/target_data_if_logical_codegen.cpp
@@ -0,0 +1,120 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --replace-value-regex 
"__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" 
"pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _ --version 3
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Check same results after serialization round-trip
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -include-pch %t -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+extern bool foo(bool);
+
+int if_logical() {
+  bool a = foo(true);
+  bool b = foo(true);
+  int pp = 42;
+  int *p = &pp;
+  #pragma omp target data if(a && b) map(to: p[0])
+  {
+p[0]++;
+  }
+  if (p[0])
+return 1;
+  return 0;
+}
+
+int main() {
+  return if_logical();
+}
+
+#endif
+// CHECK-LABEL: define dso_local noundef i32 @_Z10if_logicalv(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[A:%.*]] = alloca i8, align 1
+// CHECK-NEXT:[[B:%.*]] = alloca i8, align 1
+// CHECK-NEXT:[[PP:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[P:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[DOTOFF

[clang] [clang][OpenMP] Fix target data if/logical expression assert fail (PR #70268)

2023-10-26 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/70268
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-02-15 Thread David Pagan via cfe-commits

ddpagan wrote:

Ping.

https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #87278)

2024-04-10 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/87278
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP][NFC] Remove unnecessary nullptr check (PR #94680)

2024-06-07 Thread David Pagan via cfe-commits

https://github.com/ddpagan commented:

LGTM.

https://github.com/llvm/llvm-project/pull/94680
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (PR #114883)

2024-11-05 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/114883

>From 0959f99f541f7e10e3f761b062948f2408afc0fd Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Mon, 14 Oct 2024 15:27:56 -0500
Subject: [PATCH 1/2] [clang][OpenMP] Add 'allocator' modifier for 'allocate'
 clause.

The 'allocator' modifier is now accepted in the 'allocate' clause.
Added LIT tests covering codegen, PCH, template handling, and
serialization for 'allocator' modifier.

Added support for allocator-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
- relevant sollve_vv test cases
tests/5.2/scope/test_scope_allocate_construct.c
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  39 ++-
 clang/include/clang/Basic/OpenMPKinds.def |   7 +
 clang/include/clang/Basic/OpenMPKinds.h   |   7 +
 clang/include/clang/Sema/SemaOpenMP.h |   9 +-
 clang/lib/AST/OpenMPClause.cpp|  22 +-
 clang/lib/Basic/OpenMPKinds.cpp   |  17 +-
 clang/lib/Parse/ParseOpenMP.cpp   |  28 +-
 clang/lib/Sema/SemaOpenMP.cpp |  21 +-
 clang/lib/Sema/TreeTransform.h|  10 +-
 clang/lib/Serialization/ASTReader.cpp |   1 +
 clang/lib/Serialization/ASTWriter.cpp |   1 +
 .../allocate_allocator_modifier_ast_print.cpp |  86 ++
 .../allocate_allocator_modifier_codegen.cpp   | 255 ++
 .../allocate_allocator_modifier_messages.cpp  |  97 +++
 15 files changed, 573 insertions(+), 28 deletions(-)
 create mode 100644 clang/test/OpenMP/allocate_allocator_modifier_ast_print.cpp
 create mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dc45202f6b2e86..f07bc5044c9258 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -888,6 +888,7 @@ OpenMP Support
 --
 - Added support for 'omp assume' directive.
 - Added support for 'omp scope' directive.
+- Added support for allocator-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 9cf46f73f6e46d..00c87e71bde31b 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -486,7 +486,8 @@ class OMPAlignClause final
 /// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
 /// \endcode
 /// In this example directive '#pragma omp parallel' has clause 'private'
-/// and clause 'allocate' for the variable 'a'.
+/// and clause 'allocate' for the variable 'a', which specifies an explicit
+/// memory allocator.
 class OMPAllocateClause final
 : public OMPVarListClause,
   private llvm::TrailingObjects {
@@ -499,6 +500,10 @@ class OMPAllocateClause final
   Expr *Allocator = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
+  /// Modifier of 'allocate' clause.
+  OpenMPAllocateClauseModifier AllocatorModifier = OMPC_ALLOCATE_unknown;
+  /// Location of allocator modifier if any.
+  SourceLocation AllocatorModifierLoc;
 
   /// Build clause with number of variables \a N.
   ///
@@ -510,10 +515,14 @@ class OMPAllocateClause final
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
 Expr *Allocator, SourceLocation ColonLoc,
-SourceLocation EndLoc, unsigned N)
+OpenMPAllocateClauseModifier AllocatorModifier,
+SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
+unsigned N)
   : OMPVarListClause(llvm::omp::OMPC_allocate, StartLoc,
 LParenLoc, EndLoc, N),
-Allocator(Allocator), ColonLoc(ColonLoc) {}
+Allocator(Allocator), ColonLoc(ColonLoc),
+AllocatorModifier(AllocatorModifier),
+AllocatorModifierLoc(AllocatorModifierLoc) {}
 
   /// Build an empty clause.
   ///
@@ -527,6 +536,9 @@ class OMPAllocateClause final
   void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
 
   void setAllocator(Expr *A) { Allocator = A; }
+  void setAllocatorModifier(OpenMPAllocateClauseModifier AM) {
+AllocatorModifier = AM;
+  }
 
 public:
   /// Creates clause with a list of variables \a VL.
@@ -536,18 +548,31 @@ class OMPAllocateClause final
   /// \param LParenLoc Location of '('.
   /// \param Allocator Allocator expression.
   /// \param ColonLoc Location of ':' delimiter.
+  /// \param AllocatorModifier Allocator modifier.
+  /// \param SourceLocation Allocator modifier location.
   /// \param EndLoc Ending location of the clause.
   /// \param VL List of references to the variables.
-  static OMPAllocateClause *Create(const ASTConte

[clang] [clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (PR #114883)

2024-11-05 Thread David Pagan via cfe-commits


@@ -2242,9 +2247,16 @@ void 
OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
   if (Node->varlist_empty())
 return;
   OS << "allocate";
+  OpenMPAllocateClauseModifier Modifier = Node->getAllocatorModifier();
   if (Expr *Allocator = Node->getAllocator()) {
 OS << "(";
-Allocator->printPretty(OS, nullptr, Policy, 0);
+if (Modifier == OMPC_ALLOCATE_allocator) {
+  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier);
+  OS << "(";
+  Allocator->printPretty(OS, nullptr, Policy, 0);
+  OS << ")";
+} else
+  Allocator->printPretty(OS, nullptr, Policy, 0);

ddpagan wrote:

Fixed as suggested.

https://github.com/llvm/llvm-project/pull/114883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (PR #114883)

2024-11-05 Thread David Pagan via cfe-commits


@@ -4539,6 +4539,8 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
   bool NeedRParenForLinear = false;
   BalancedDelimiterTracker LinearT(*this, tok::l_paren,
tok::annot_pragma_openmp_end);
+  BalancedDelimiterTracker AllocateT(*this, tok::l_paren,
+ tok::annot_pragma_openmp_end);

ddpagan wrote:

Fixed as suggested.

https://github.com/llvm/llvm-project/pull/114883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (PR #114883)

2024-11-05 Thread David Pagan via cfe-commits

ddpagan wrote:

@alexey-bataev - I'll make that change in the next PR. Thanks for the review.

https://github.com/llvm/llvm-project/pull/114883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (PR #114883)

2024-11-05 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/114883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP][NFC] Move 'allocate' clause modifier parsing into fun… (PR #115775)

2024-11-11 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/115775

…ction

Parsing of 'allocate' clause modifier ('allocator') has been moved into a 
separate function in anticipation of adding another modifier ('align').

>From 78e9809b743f74207dfab2e2271d91a04b2f75ca Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Mon, 11 Nov 2024 14:41:47 -0600
Subject: [PATCH] [clang][OpenMP][NFC] Move 'allocate' clause modifier parsing
 into function

Parsing of 'allocate' clause modifier ('allocator') has been moved into
a separate function in anticipation of adding another modifier ('align').
---
 clang/lib/Parse/ParseOpenMP.cpp | 48 +
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 59a33eafa6be4f..c253133f611b0b 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4519,6 +4519,36 @@ static bool parseStepSize(Parser &P, 
SemaOpenMP::OpenMPVarListDataTy &Data,
   return false;
 }
 
+/// Parse 'allocate' clause modifiers.
+///   If allocator-modifier exists, return an expression for it and set
+///   Data field noting modifier was specified.
+///
+static ExprResult
+parseOpenMPAllocateClauseModifiers(Parser &P, OpenMPClauseKind Kind,
+   SemaOpenMP::OpenMPVarListDataTy &Data) {
+  const Token &Tok = P.getCurToken();
+  Preprocessor &PP = P.getPreprocessor();
+  ExprResult Tail;
+  auto Modifier = static_cast(
+  getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok), P.getLangOpts()));
+  if (Modifier == OMPC_ALLOCATE_allocator) {
+Data.AllocClauseModifier = Modifier;
+P.ConsumeToken();
+BalancedDelimiterTracker AllocateT(P, tok::l_paren,
+   tok::annot_pragma_openmp_end);
+if (Tok.is(tok::l_paren)) {
+  AllocateT.consumeOpen();
+  Tail = P.ParseAssignmentExpression();
+  AllocateT.consumeClose();
+} else {
+  P.Diag(Tok, diag::err_expected) << tok::l_paren;
+}
+  } else {
+Tail = P.ParseAssignmentExpression();
+  }
+  return Tail;
+}
+
 /// Parses clauses with list.
 bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
 OpenMPClauseKind Kind,
@@ -4800,23 +4830,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind 
DKind,
 // iterator(iterators-definition)
 ExprResult Tail;
 if (Kind == OMPC_allocate) {
-  auto Modifier = static_cast(
-  getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok), getLangOpts()));
-  if (Modifier == OMPC_ALLOCATE_allocator) {
-Data.AllocClauseModifier = Modifier;
-ConsumeToken();
-BalancedDelimiterTracker AllocateT(*this, tok::l_paren,
-   tok::annot_pragma_openmp_end);
-if (Tok.is(tok::l_paren)) {
-  AllocateT.consumeOpen();
-  Tail = ParseAssignmentExpression();
-  AllocateT.consumeClose();
-} else {
-  Diag(Tok, diag::err_expected) << tok::l_paren;
-}
-  } else {
-Tail = ParseAssignmentExpression();
-  }
+  Tail = parseOpenMPAllocateClauseModifiers(*this, Kind, Data);
 } else {
   HasIterator = true;
   EnterScope(Scope::OpenMPDirectiveScope | Scope::DeclScope);

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP][NFC] Move 'allocate' clause modifier parsing into fun… (PR #115775)

2024-11-11 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/115775
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][Docs] Update OpenMP supported features table (PR #109726)

2024-09-23 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/109726

OpenMP features table: updated scope directive status from 'worked on' to 
'done' in section OpenMP 5.1 Implementation Details.

>From 1827e1189aaaf2dc3945a744e249ea77b4acc6c0 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Mon, 23 Sep 2024 17:36:36 -0500
Subject: [PATCH] [OpenMP][Docs] Update OpenMP supported features table

OpenMP features table: updated scope directive status from 'worked on'
to 'done' in section OpenMP 5.1 Implementation Details.
---
 clang/docs/OpenMPSupport.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 72f13856a056e2..6c7afc12b44ebb 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -294,7 +294,7 @@ implementation.
 
+--+--+--+---+
 | misc | error directive   
   | :good:`done` | D139166 
  |
 
+--+--+--+---+
-| misc | scope construct   
   | :none:`worked on`| D157933 
  |
+| misc | scope construct   
   | :good:`done` | D157933, 
https://github.com/llvm/llvm-project/pull/109197 |
 
+--+--+--+---+
 | misc | routines for controlling and querying team 
regions   | :part:`partial`  | D95003 (libomp only) 
 |
 
+--+--+--+---+

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][Docs] Update OpenMP release notes with 'omp scope' (PR #109752)

2024-09-23 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/109752

Release notes: added 'omp scope' directive to "OpenMP Support" section of 
"What's New in Clang"

>From 6ded6531f20d4f2a8eee5e0263d2ff87da17e8d8 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Mon, 23 Sep 2024 23:57:25 -0500
Subject: [PATCH] [OpenMP][Docs] Update OpenMP release notes with 'omp scope'

Release notes: added 'omp scope' directive to "OpenMP Support" section
of "What's New in Clang"
---
 clang/docs/ReleaseNotes.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b47e06cb0c5d68..e511614fcf2451 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -637,6 +637,7 @@ Python Binding Changes
 OpenMP Support
 --
 - Added support for 'omp assume' directive.
+- Added support for 'omp scope' directive.
 
 Improvements
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][Docs] Update OpenMP supported features table (PR #109726)

2024-09-23 Thread David Pagan via cfe-commits

ddpagan wrote:

Thanks, Alexey. I'll do that.

https://github.com/llvm/llvm-project/pull/109726
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][Docs] Update OpenMP supported features table (PR #109726)

2024-09-23 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/109726
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][Docs] Update OpenMP release notes with 'omp scope' (PR #109752)

2024-09-24 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/109752
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][OpenMP] Add codegen for scope directive (PR #109197)

2024-09-19 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/109197
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][OpenMP] Add codegen for scope directive (PR #109197)

2024-09-19 Thread David Pagan via cfe-commits


@@ -0,0 +1,2267 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex 
"__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" 
"pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm 
%s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=CHECK1
+
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 
-include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK1
+
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 
-include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK4
+
+// RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -std=c++11 
-fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -fexceptions -fcxx-exceptions 
-debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK5
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK6
+
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm 
%s -fexceptions -fcxx-exceptions -o - | FileCheck %s 
--implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -std=c++11 
-fopenmp-simd -fopenmp-version=52 -fnoopenmp-use-tls -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// expected-no-diagnostics
+
+typedef void **omp_allocator_handle_t;
+extern const omp_allocator_handle_t omp_null_allocator;
+extern const omp_allocator_handle_t omp_default_mem_alloc;
+extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
+extern const omp_allocator_handle_t omp_const_mem_alloc;
+extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
+extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
+extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
+extern const omp_allocator_handle_t omp_pteam_mem_alloc;
+extern const omp_allocator_handle_t omp_thread_mem_alloc;

ddpagan wrote:

Thanks for catching this, Alexey. They aren't necessary. It was a cut/paste 
error as I was creating the test. I'll remove them.

https://github.com/llvm/llvm-project/pull/109197
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][OpenMP] Add codegen for scope directive (PR #109197)

2024-09-19 Thread David Pagan via cfe-commits


@@ -0,0 +1,2267 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex 
"__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" 
"pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm 
%s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix=CHECK1
+
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 
-include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK1
+
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 
-include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK4
+
+// RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -std=c++11 
-fopenmp -fopenmp-version=52 -fnoopenmp-use-tls -fexceptions -fcxx-exceptions 
-debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK5
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK6
+
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm 
%s -fexceptions -fcxx-exceptions -o - | FileCheck %s 
--implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -fnoopenmp-use-tls -x c++ 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -std=c++11 
-fopenmp-simd -fopenmp-version=52 -fnoopenmp-use-tls -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -fopenmp-version=52 
-fnoopenmp-use-tls -x c++ -std=c++11 -DARRAY -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// expected-no-diagnostics
+
+typedef void **omp_allocator_handle_t;
+extern const omp_allocator_handle_t omp_null_allocator;
+extern const omp_allocator_handle_t omp_default_mem_alloc;
+extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
+extern const omp_allocator_handle_t omp_const_mem_alloc;
+extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
+extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
+extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
+extern const omp_allocator_handle_t omp_pteam_mem_alloc;
+extern const omp_allocator_handle_t omp_thread_mem_alloc;

ddpagan wrote:

@alexey-bataev - Actually, I forgot that they are needed by the test case as it 
tests using the 'allocate' clause with the scope directive.

https://github.com/llvm/llvm-project/pull/109197
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][Docs] Update OpenMP supported features table (PR #115106)

2024-11-06 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/115106
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-06 Thread David Pagan via cfe-commits

ddpagan wrote:

> Update OpenMPSupport.rst

New 'align' modifier added to implemented features list.

https://github.com/llvm/llvm-project/pull/121814
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-06 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/121814

>From c2c2c4c46c3ea615e86484b9f9a14a74fab21295 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 22 Nov 2024 10:35:40 -0600
Subject: [PATCH 1/2] [clang][OpenMP] Add 'align' modifier for 'allocate'
 clause

The 'align' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  92 +++-
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 clang/include/clang/Basic/OpenMPKinds.def |   1 +
 clang/include/clang/Basic/OpenMPKinds.h   |   4 +
 clang/include/clang/Sema/SemaOpenMP.h |  20 +-
 clang/lib/AST/OpenMPClause.cpp|  58 ++-
 clang/lib/Parse/ParseOpenMP.cpp   |  95 +++-
 clang/lib/Sema/SemaOpenMP.cpp | 102 +++--
 clang/lib/Sema/TreeTransform.h|  30 +-
 clang/lib/Serialization/ASTReader.cpp |   6 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 .../allocate_allocator_modifier_codegen.cpp   | 255 ---
 .../allocate_allocator_modifier_messages.cpp  |  97 -
 ...t.cpp => allocate_modifiers_ast_print.cpp} |  77 +++-
 .../OpenMP/allocate_modifiers_codegen.cpp | 409 ++
 .../OpenMP/allocate_modifiers_messages.cpp| 159 +++
 17 files changed, 961 insertions(+), 451 deletions(-)
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp
 rename clang/test/OpenMP/{allocate_allocator_modifier_ast_print.cpp => 
allocate_modifiers_ast_print.cpp} (51%)
 create mode 100644 clang/test/OpenMP/allocate_modifiers_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_modifiers_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index acd9dd9298ce1e..25d390f69bcea3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1284,6 +1284,7 @@ OpenMP Support
 - Changed the OpenMP DeviceRTL to use 'generic' IR. The
   ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
   always build support for AMDGPU and NVPTX targets.
+- Added support for align-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d2f5267e4da5ea..b9088eff3bb52e 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -498,6 +498,9 @@ class OMPAllocateClause final
   /// Allocator specified in the clause, or 'nullptr' if the default one is
   /// used.
   Expr *Allocator = nullptr;
+  /// Alignment specified in the clause, or 'nullptr' if the default one is
+  /// used.
+  Expr *Alignment = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
   /// Modifier of 'allocate' clause.
@@ -505,6 +508,41 @@ class OMPAllocateClause final
   /// Location of allocator modifier if any.
   SourceLocation AllocatorModifierLoc;
 
+  // 

+
+  /// Modifiers for 'allocate' clause.
+  enum { FIRST, SECOND, NUM_MODIFIERS };
+  OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
+
+  /// Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
+
+  /// Set the first allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+
+  /// Set the second allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+
+  /// Set location of the first allocate modifier.
+  void setFirstAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+
+  /// Set location of the second allocate modifier.
+  void setSecondAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+
+  // 

+
   /// Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -514,15 +552,20 @@ class OMPAllocateClause final
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-Expr *Allocator, SourceLocation ColonLoc,
-OpenMPAllocateClauseModifier AllocatorModifier,
-SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
+Expr *Allocator, Expr *Alignment, Sou

[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-06 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/121814

The 'align' modifier is now accepted in the 'allocate' clause. Added LIT tests 
covering codegen, PCH, template handling, and serialization for 'align' 
modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all

>From c2c2c4c46c3ea615e86484b9f9a14a74fab21295 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 22 Nov 2024 10:35:40 -0600
Subject: [PATCH] [clang][OpenMP] Add 'align' modifier for 'allocate' clause

The 'align' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  92 +++-
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 clang/include/clang/Basic/OpenMPKinds.def |   1 +
 clang/include/clang/Basic/OpenMPKinds.h   |   4 +
 clang/include/clang/Sema/SemaOpenMP.h |  20 +-
 clang/lib/AST/OpenMPClause.cpp|  58 ++-
 clang/lib/Parse/ParseOpenMP.cpp   |  95 +++-
 clang/lib/Sema/SemaOpenMP.cpp | 102 +++--
 clang/lib/Sema/TreeTransform.h|  30 +-
 clang/lib/Serialization/ASTReader.cpp |   6 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 .../allocate_allocator_modifier_codegen.cpp   | 255 ---
 .../allocate_allocator_modifier_messages.cpp  |  97 -
 ...t.cpp => allocate_modifiers_ast_print.cpp} |  77 +++-
 .../OpenMP/allocate_modifiers_codegen.cpp | 409 ++
 .../OpenMP/allocate_modifiers_messages.cpp| 159 +++
 17 files changed, 961 insertions(+), 451 deletions(-)
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp
 rename clang/test/OpenMP/{allocate_allocator_modifier_ast_print.cpp => 
allocate_modifiers_ast_print.cpp} (51%)
 create mode 100644 clang/test/OpenMP/allocate_modifiers_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_modifiers_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index acd9dd9298ce1e..25d390f69bcea3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1284,6 +1284,7 @@ OpenMP Support
 - Changed the OpenMP DeviceRTL to use 'generic' IR. The
   ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
   always build support for AMDGPU and NVPTX targets.
+- Added support for align-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d2f5267e4da5ea..b9088eff3bb52e 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -498,6 +498,9 @@ class OMPAllocateClause final
   /// Allocator specified in the clause, or 'nullptr' if the default one is
   /// used.
   Expr *Allocator = nullptr;
+  /// Alignment specified in the clause, or 'nullptr' if the default one is
+  /// used.
+  Expr *Alignment = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
   /// Modifier of 'allocate' clause.
@@ -505,6 +508,41 @@ class OMPAllocateClause final
   /// Location of allocator modifier if any.
   SourceLocation AllocatorModifierLoc;
 
+  // 

+
+  /// Modifiers for 'allocate' clause.
+  enum { FIRST, SECOND, NUM_MODIFIERS };
+  OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
+
+  /// Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
+
+  /// Set the first allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+
+  /// Set the second allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+
+  /// Set location of the first allocate modifier.
+  void setFirstAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+
+  /// Set location of the second allocate modifier.
+  void setSecondAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+
+  // 

+
   /// Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -514,15 +552,20 @@ class OMPAllocateClause final
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLoca

[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-06 Thread David Pagan via cfe-commits

ddpagan wrote:

NOTE: OpenMP Support doc will be updated as well in a subsequent patch.

https://github.com/llvm/llvm-project/pull/121814
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-07 Thread David Pagan via cfe-commits

ddpagan wrote:

Thanks for reviewing, Alexey. Made the requested changes.

https://github.com/llvm/llvm-project/pull/121814
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-07 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/121814

>From c2c2c4c46c3ea615e86484b9f9a14a74fab21295 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 22 Nov 2024 10:35:40 -0600
Subject: [PATCH 1/3] [clang][OpenMP] Add 'align' modifier for 'allocate'
 clause

The 'align' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  92 +++-
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 clang/include/clang/Basic/OpenMPKinds.def |   1 +
 clang/include/clang/Basic/OpenMPKinds.h   |   4 +
 clang/include/clang/Sema/SemaOpenMP.h |  20 +-
 clang/lib/AST/OpenMPClause.cpp|  58 ++-
 clang/lib/Parse/ParseOpenMP.cpp   |  95 +++-
 clang/lib/Sema/SemaOpenMP.cpp | 102 +++--
 clang/lib/Sema/TreeTransform.h|  30 +-
 clang/lib/Serialization/ASTReader.cpp |   6 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 .../allocate_allocator_modifier_codegen.cpp   | 255 ---
 .../allocate_allocator_modifier_messages.cpp  |  97 -
 ...t.cpp => allocate_modifiers_ast_print.cpp} |  77 +++-
 .../OpenMP/allocate_modifiers_codegen.cpp | 409 ++
 .../OpenMP/allocate_modifiers_messages.cpp| 159 +++
 17 files changed, 961 insertions(+), 451 deletions(-)
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp
 rename clang/test/OpenMP/{allocate_allocator_modifier_ast_print.cpp => 
allocate_modifiers_ast_print.cpp} (51%)
 create mode 100644 clang/test/OpenMP/allocate_modifiers_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_modifiers_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index acd9dd9298ce1e..25d390f69bcea3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1284,6 +1284,7 @@ OpenMP Support
 - Changed the OpenMP DeviceRTL to use 'generic' IR. The
   ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
   always build support for AMDGPU and NVPTX targets.
+- Added support for align-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d2f5267e4da5ea..b9088eff3bb52e 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -498,6 +498,9 @@ class OMPAllocateClause final
   /// Allocator specified in the clause, or 'nullptr' if the default one is
   /// used.
   Expr *Allocator = nullptr;
+  /// Alignment specified in the clause, or 'nullptr' if the default one is
+  /// used.
+  Expr *Alignment = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
   /// Modifier of 'allocate' clause.
@@ -505,6 +508,41 @@ class OMPAllocateClause final
   /// Location of allocator modifier if any.
   SourceLocation AllocatorModifierLoc;
 
+  // 

+
+  /// Modifiers for 'allocate' clause.
+  enum { FIRST, SECOND, NUM_MODIFIERS };
+  OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
+
+  /// Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
+
+  /// Set the first allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+
+  /// Set the second allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+
+  /// Set location of the first allocate modifier.
+  void setFirstAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+
+  /// Set location of the second allocate modifier.
+  void setSecondAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+
+  // 

+
   /// Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -514,15 +552,20 @@ class OMPAllocateClause final
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-Expr *Allocator, SourceLocation ColonLoc,
-OpenMPAllocateClauseModifier AllocatorModifier,
-SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
+Expr *Allocator, Expr *Alignment, Sou

[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-07 Thread David Pagan via cfe-commits


@@ -5285,6 +5285,7 @@ static void checkAllocateClauses(Sema &S, DSAStackTy 
*Stack,
   }
   for (OMPClause *C : AllocateRange) {
 auto *AC = cast(C);
+// TODO: Check alignment?

ddpagan wrote:

Old note to myself.  As far as I know there aren't any checks required here.

https://github.com/llvm/llvm-project/pull/121814
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] OpenMP 6.0 updates to restrictions with order/concurrent (PR #125621)

2025-02-03 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/125621

>From OpenMP 6.0 features list
- OpenMP directives in concurrent loop regions
- atomics constructs on concurrent loop regions
- Lift nesting restriction on concurrent loop

Testing
- Updated test/OpenMP/for_order_messages.cpp
- check-all

>From deffda7ca37661781f1bae565ac8ae4a8fbba674 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 31 Jan 2025 16:12:08 -0600
Subject: [PATCH] [clang][OpenMP] OpenMP 6.0 updates to restrictions with
 order/concurrent

>From OpenMP 6.0 features list
- OpenMP directives in concurrent loop regions
- atomics constructs on concurrent loop regions
- Lift nesting restriction on concurrent loop

Testing
- Updated test/OpenMP/for_order_messages.cpp
- check-all
---
 clang/include/clang/Basic/OpenMPKinds.h  |  8 +++
 clang/lib/Basic/OpenMPKinds.cpp  |  6 +
 clang/lib/Sema/SemaOpenMP.cpp| 30 +---
 clang/test/OpenMP/for_order_messages.cpp | 12 ++
 4 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index 3e5da2a6abc0171..e80bce34a97e037 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -399,6 +399,14 @@ bool isOpenMPInformationalDirective(OpenMPDirectiveKind 
DKind);
 /// \return true - if the above condition is met for this directive
 /// otherwise - false.
 bool isOpenMPCapturingDirective(OpenMPDirectiveKind DKind);
+
+/// Checks if the specified directive is an order concurrent nestable
+/// directive that can be nested within region corresponding to construct
+/// on which order clause was specified with concurrent as ordering argument.
+/// \param DKind Specified directive.
+/// \return true - if the above condition is met for this directive
+/// otherwise - false.
+bool isOpenMPOrderConcurrentNestableDirective(OpenMPDirectiveKind DKind);
 }
 
 template <>
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 62a13f01481b28b..8398eabceb82fe5 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -765,6 +765,12 @@ bool clang::isOpenMPCapturingDirective(OpenMPDirectiveKind 
DKind) {
   return false;
 }
 
+bool clang::isOpenMPOrderConcurrentNestableDirective(OpenMPDirectiveKind 
DKind) {
+  return DKind == OMPD_atomic || DKind == OMPD_loop ||
+ DKind == OMPD_simd || DKind == OMPD_parallel ||
+ isOpenMPLoopTransformationDirective(DKind);
+}
+
 void clang::getOpenMPCaptureRegions(
 SmallVectorImpl &CaptureRegions,
 OpenMPDirectiveKind DKind) {
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index b83b2b12f4a230f..3bba93c9560041a 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4788,13 +4788,26 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
   getLeafOrCompositeConstructs(ParentRegion, LeafOrComposite);
   OpenMPDirectiveKind EnclosingConstruct = ParentLOC.back();
 
-  if (SemaRef.LangOpts.OpenMP >= 51 && Stack->isParentOrderConcurrent() &&
-  CurrentRegion != OMPD_simd && CurrentRegion != OMPD_loop &&
-  CurrentRegion != OMPD_parallel &&
-  !isOpenMPCombinedParallelADirective(CurrentRegion)) {
-SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order)
-<< getOpenMPDirectiveName(CurrentRegion);
-return true;
+  if (Stack->isParentOrderConcurrent()) {
+bool InvalidOrderNesting = false; 
+if ((SemaRef.LangOpts.OpenMP == 51 || SemaRef.LangOpts.OpenMP == 52) &&
+CurrentRegion != OMPD_simd &&
+CurrentRegion != OMPD_loop && CurrentRegion != OMPD_parallel &&
+!isOpenMPCombinedParallelADirective(CurrentRegion)) {
+  InvalidOrderNesting = true;
+} else if (SemaRef.LangOpts.OpenMP >= 60 &&
+!isOpenMPOrderConcurrentNestableDirective(CurrentRegion)) {
+  // OpenMP 6.0 [12.3 order Clause, Restrictions]
+  // Only regions that correspond to order-concurrent-nestable constructs
+  // or order-concurrent-nestable routines may be strictly nested regions
+  // of regions that correspond to constructs on which the order clause is
+  // specified with concurrent as the ordering argument.
+  InvalidOrderNesting = true;
+}
+if (InvalidOrderNesting) {
+  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order)
+  << getOpenMPDirectiveName(CurrentRegion);
+}
   }
   if (isOpenMPSimdDirective(ParentRegion) &&
   ((SemaRef.LangOpts.OpenMP <= 45 && CurrentRegion != OMPD_ordered) ||
@@ -7114,7 +7127,8 @@ ExprResult SemaOpenMP::ActOnOpenMPCall(ExprResult Call, 
Scope *Scope,
   if (!CalleeFnDecl)
 return Call;
 
-  if (getLangOpts().OpenMP >= 51 && CalleeFnDecl->getIdentifier() &&
+  if (getLangOpts().OpenMP >= 51 && getLangOpts().OpenMP < 60 &&
+  CalleeFnDecl->getIdentifier() &&
   CalleeFnDecl->getN

[clang] [clang][OpenMP] OpenMP 6.0 updates to restrictions with order/concurrent (PR #125621)

2025-02-04 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/125621

>From deffda7ca37661781f1bae565ac8ae4a8fbba674 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 31 Jan 2025 16:12:08 -0600
Subject: [PATCH 1/3] [clang][OpenMP] OpenMP 6.0 updates to restrictions with
 order/concurrent

>From OpenMP 6.0 features list
- OpenMP directives in concurrent loop regions
- atomics constructs on concurrent loop regions
- Lift nesting restriction on concurrent loop

Testing
- Updated test/OpenMP/for_order_messages.cpp
- check-all
---
 clang/include/clang/Basic/OpenMPKinds.h  |  8 +++
 clang/lib/Basic/OpenMPKinds.cpp  |  6 +
 clang/lib/Sema/SemaOpenMP.cpp| 30 +---
 clang/test/OpenMP/for_order_messages.cpp | 12 ++
 4 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index 3e5da2a6abc017..e80bce34a97e03 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -399,6 +399,14 @@ bool isOpenMPInformationalDirective(OpenMPDirectiveKind 
DKind);
 /// \return true - if the above condition is met for this directive
 /// otherwise - false.
 bool isOpenMPCapturingDirective(OpenMPDirectiveKind DKind);
+
+/// Checks if the specified directive is an order concurrent nestable
+/// directive that can be nested within region corresponding to construct
+/// on which order clause was specified with concurrent as ordering argument.
+/// \param DKind Specified directive.
+/// \return true - if the above condition is met for this directive
+/// otherwise - false.
+bool isOpenMPOrderConcurrentNestableDirective(OpenMPDirectiveKind DKind);
 }
 
 template <>
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 62a13f01481b28..8398eabceb82fe 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -765,6 +765,12 @@ bool clang::isOpenMPCapturingDirective(OpenMPDirectiveKind 
DKind) {
   return false;
 }
 
+bool clang::isOpenMPOrderConcurrentNestableDirective(OpenMPDirectiveKind 
DKind) {
+  return DKind == OMPD_atomic || DKind == OMPD_loop ||
+ DKind == OMPD_simd || DKind == OMPD_parallel ||
+ isOpenMPLoopTransformationDirective(DKind);
+}
+
 void clang::getOpenMPCaptureRegions(
 SmallVectorImpl &CaptureRegions,
 OpenMPDirectiveKind DKind) {
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index b83b2b12f4a230..3bba93c9560041 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4788,13 +4788,26 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
   getLeafOrCompositeConstructs(ParentRegion, LeafOrComposite);
   OpenMPDirectiveKind EnclosingConstruct = ParentLOC.back();
 
-  if (SemaRef.LangOpts.OpenMP >= 51 && Stack->isParentOrderConcurrent() &&
-  CurrentRegion != OMPD_simd && CurrentRegion != OMPD_loop &&
-  CurrentRegion != OMPD_parallel &&
-  !isOpenMPCombinedParallelADirective(CurrentRegion)) {
-SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order)
-<< getOpenMPDirectiveName(CurrentRegion);
-return true;
+  if (Stack->isParentOrderConcurrent()) {
+bool InvalidOrderNesting = false; 
+if ((SemaRef.LangOpts.OpenMP == 51 || SemaRef.LangOpts.OpenMP == 52) &&
+CurrentRegion != OMPD_simd &&
+CurrentRegion != OMPD_loop && CurrentRegion != OMPD_parallel &&
+!isOpenMPCombinedParallelADirective(CurrentRegion)) {
+  InvalidOrderNesting = true;
+} else if (SemaRef.LangOpts.OpenMP >= 60 &&
+!isOpenMPOrderConcurrentNestableDirective(CurrentRegion)) {
+  // OpenMP 6.0 [12.3 order Clause, Restrictions]
+  // Only regions that correspond to order-concurrent-nestable constructs
+  // or order-concurrent-nestable routines may be strictly nested regions
+  // of regions that correspond to constructs on which the order clause is
+  // specified with concurrent as the ordering argument.
+  InvalidOrderNesting = true;
+}
+if (InvalidOrderNesting) {
+  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order)
+  << getOpenMPDirectiveName(CurrentRegion);
+}
   }
   if (isOpenMPSimdDirective(ParentRegion) &&
   ((SemaRef.LangOpts.OpenMP <= 45 && CurrentRegion != OMPD_ordered) ||
@@ -7114,7 +7127,8 @@ ExprResult SemaOpenMP::ActOnOpenMPCall(ExprResult Call, 
Scope *Scope,
   if (!CalleeFnDecl)
 return Call;
 
-  if (getLangOpts().OpenMP >= 51 && CalleeFnDecl->getIdentifier() &&
+  if (getLangOpts().OpenMP >= 51 && getLangOpts().OpenMP < 60 &&
+  CalleeFnDecl->getIdentifier() &&
   CalleeFnDecl->getName().starts_with_insensitive("omp_")) {
 // checking for any calls inside an Order region
 if (Scope && Scope->isOpenMPOrderClauseScope())
diff --git a/clang/test/OpenMP/for_order_messages.cpp 
b/clang/test/OpenMP/for_order_messages

[clang] [clang][OpenMP] OpenMP 6.0 updates to restrictions with order/concurrent (PR #125621)

2025-02-05 Thread David Pagan via cfe-commits

ddpagan wrote:

@alexey-bataev - question: I didn't see an approval from you but the PR says 
that I can merge. Did I miss something?

https://github.com/llvm/llvm-project/pull/125621
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][OpenMP] New OpenMP 6.0 assumption clause, 'no_openmp_construc… (PR #125933)

2025-02-05 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/125933

…ts'.

Add initial parsing/sema support for new assumption clause so clause can be 
specified. For now, it's ignored, just like the others.

Added support for 'no_openmp_construct' to release notes.

Testing
- Updated appropriate LIT tests.
- Testing: check-all

>From 86069865d3ae356593c7a28f99cc1a4ec53f3120 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Thu, 30 Jan 2025 10:53:30 -0600
Subject: [PATCH] [clang][OpenMP] New OpenMP 6.0 assumption clause,
 'no_openmp_constructs'.

Add initial parsing/sema support for new assumption clause so clause can
be specified. For now, it's ignored, just like the others.

Added support for 'no_openmp_construct' to release notes.

Testing
- Updated appropriate LIT tests.
- Testing: check-all
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/include/clang/AST/OpenMPClause.h| 22 ++
 clang/include/clang/AST/RecursiveASTVisitor.h |  6 +++
 clang/include/clang/Basic/AttrDocs.td |  1 +
 clang/lib/AST/OpenMPClause.cpp|  5 +++
 clang/lib/AST/StmtProfile.cpp |  3 ++
 clang/lib/Parse/ParseOpenMP.cpp   |  2 +
 clang/lib/Sema/SemaOpenMP.cpp |  2 +
 clang/lib/Sema/TreeTransform.h|  5 +++
 clang/lib/Serialization/ASTReader.cpp |  6 +++
 clang/lib/Serialization/ASTWriter.cpp |  3 ++
 clang/test/OpenMP/assume_lambda.cpp   |  8 +++-
 clang/test/OpenMP/assume_nesting_tmpl.cpp | 10 -
 clang/test/OpenMP/assume_template.cpp | 12 +++--
 clang/test/OpenMP/assumes_codegen.cpp | 18 
 clang/test/OpenMP/assumes_messages.c  | 44 +--
 clang/test/OpenMP/assumes_messages_attr.c | 28 ++--
 clang/test/OpenMP/assumes_print.cpp   | 19 
 clang/test/OpenMP/attr-assume.cpp |  3 +-
 clang/tools/libclang/CIndex.cpp   |  3 ++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  4 ++
 .../include/llvm/Frontend/OpenMP/OMPKinds.def |  1 +
 llvm/lib/IR/Assumptions.cpp   | 13 +++---
 llvm/lib/Transforms/IPO/OpenMPOpt.cpp |  3 +-
 llvm/test/Transforms/OpenMP/icv_tracking.ll   |  2 +
 25 files changed, 157 insertions(+), 67 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 21c1ff25d2862ba..d45e46cab3f923a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -262,6 +262,7 @@ Python Binding Changes
 
 OpenMP Support
 --
+- Added support 'no_openmp_constructs' assumption clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index abdf9333e7125c4..154ecfbaa441820 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2423,6 +2423,28 @@ class OMPNoOpenMPRoutinesClause final
   OMPNoOpenMPRoutinesClause() : OMPNoChildClause() {}
 };
 
+/// This represents the 'no_openmp_constructs' clause in the
+ '#pragma omp assume' directive.
+///
+/// \code
+/// #pragma omp assume no_openmp_constructs
+/// \endcode
+/// In this example directive '#pragma omp assume' has a 'no_openmp_constructs'
+/// clause.
+class OMPNoOpenMPConstructsClause final
+: public OMPNoChildClause {
+public:
+  /// Build 'no_openmp_constructs' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPNoOpenMPConstructsClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPNoChildClause(StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPNoOpenMPConstructsClause() : OMPNoChildClause() {}
+};
+
 /// This represents the 'no_parallelism' clause in the '#pragma omp assume'
 /// directive.
 ///
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 55505794e70542c..06c762c080de09d 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3544,6 +3544,12 @@ bool 
RecursiveASTVisitor::VisitOMPNoOpenMPRoutinesClause(
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPNoOpenMPConstructsClause(
+OMPNoOpenMPConstructsClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPNoParallelismClause(
 OMPNoParallelismClause *) {
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a8b588169725a2c..0ad4c958d098303 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5274,6 +5274,7 @@ optimization passes are aware of the following 
assumptions:
 "omp_no_openmp"
 "omp_no_openmp_routines"
 "omp_no_parallelism"
+"omp_no_openmp_constructs"
 
 The OpenMP standard defines the meaning of OpenMP assumptions ("omp_XYZ" is
 spelled "XYZ" in the `OpenMP 5.1 Standard`_).
diff --git a/c

[clang] [OpenMP][Docs] Update OpenMP supported features table (PR #126292)

2025-02-07 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/126292
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][Docs] Update OpenMP supported features table (PR #126292)

2025-02-07 Thread David Pagan via cfe-commits

https://github.com/ddpagan created 
https://github.com/llvm/llvm-project/pull/126292

Updated status to 'done' for OpenMP 6.0 features:
  - OpenMP directives in concurrent loop regions
  - atomics constructs on concurrent loop regions
  - Lift nesting restriction on concurrent loop

Removed duplicate OpenMP 6.0 feature per Michael Klemm:
  - atomic constructs in loop region

>From 8e2b7fb4164b42faa25a0bfe33d46003d016cc2d Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 7 Feb 2025 13:16:44 -0600
Subject: [PATCH] [OpenMP][Docs] Update OpenMP supported features table

Updated status to 'done' for OpenMP 6.0 features:
  - OpenMP directives in concurrent loop regions
  - atomics constructs on concurrent loop regions
  - Lift nesting restriction on concurrent loop

Removed duplicate OpenMP 6.0 feature per Michael Klemm:
  - atomic constructs in loop region
---
 clang/docs/OpenMPSupport.rst | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index c31d6e90ecb084f..725624ee8c66cd8 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -416,9 +416,9 @@ implementation.
 
+-+---+---+--+
 | safe_sync and progress with identifier and API  | 
:none:`unclaimed` | :none:`unclaimed` | 
 |
 
+-+---+---+--+
-| OpenMP directives in concurrent loop regions| 
:none:`unclaimed` | :none:`unclaimed` | 
 |
+| OpenMP directives in concurrent loop regions| :good:`done`   
   | :none:`unclaimed` | 
https://github.com/llvm/llvm-project/pull/125621 |
 
+-+---+---+--+
-| atomics constructs on concurrent loop regions   | 
:none:`unclaimed` | :none:`unclaimed` | 
 |
+| atomics constructs on concurrent loop regions   | :good:`done`   
   | :none:`unclaimed` | 
https://github.com/llvm/llvm-project/pull/125621 |
 
+-+---+---+--+
 | Loop construct with DO CONCURRENT   | 
:none:`unclaimed` | :none:`unclaimed` | 
 |
 
+-+---+---+--+
@@ -456,9 +456,7 @@ implementation.
 
+-+---+---+--+
 | map-type modifiers in arbitrary position| 
:none:`unclaimed` | :none:`unclaimed` | 
 |
 
+-+---+---+--+
-| atomic constructs in loop region| 
:none:`unclaimed` | :none:`unclaimed` | 
 |
-+-+---+---+--+
-| Lift nesting restriction on concurrent loop | 
:none:`unclaimed` | :none:`unclaimed` | 
 |
+| Lift nesting restriction on concurrent loop | :good:`done`   
   | :none:`unclaimed` | 
https://github.com/llvm/llvm-project/pull/125621 |
 
+-+---+---+--+
 | priority clause f

[clang] [llvm] [clang][OpenMP] New OpenMP 6.0 assumption clause, 'no_openmp_constructs' (PR #125933)

2025-02-06 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/125933

>From 86069865d3ae356593c7a28f99cc1a4ec53f3120 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Thu, 30 Jan 2025 10:53:30 -0600
Subject: [PATCH 1/2] [clang][OpenMP] New OpenMP 6.0 assumption clause,
 'no_openmp_constructs'.

Add initial parsing/sema support for new assumption clause so clause can
be specified. For now, it's ignored, just like the others.

Added support for 'no_openmp_construct' to release notes.

Testing
- Updated appropriate LIT tests.
- Testing: check-all
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/include/clang/AST/OpenMPClause.h| 22 ++
 clang/include/clang/AST/RecursiveASTVisitor.h |  6 +++
 clang/include/clang/Basic/AttrDocs.td |  1 +
 clang/lib/AST/OpenMPClause.cpp|  5 +++
 clang/lib/AST/StmtProfile.cpp |  3 ++
 clang/lib/Parse/ParseOpenMP.cpp   |  2 +
 clang/lib/Sema/SemaOpenMP.cpp |  2 +
 clang/lib/Sema/TreeTransform.h|  5 +++
 clang/lib/Serialization/ASTReader.cpp |  6 +++
 clang/lib/Serialization/ASTWriter.cpp |  3 ++
 clang/test/OpenMP/assume_lambda.cpp   |  8 +++-
 clang/test/OpenMP/assume_nesting_tmpl.cpp | 10 -
 clang/test/OpenMP/assume_template.cpp | 12 +++--
 clang/test/OpenMP/assumes_codegen.cpp | 18 
 clang/test/OpenMP/assumes_messages.c  | 44 +--
 clang/test/OpenMP/assumes_messages_attr.c | 28 ++--
 clang/test/OpenMP/assumes_print.cpp   | 19 
 clang/test/OpenMP/attr-assume.cpp |  3 +-
 clang/tools/libclang/CIndex.cpp   |  3 ++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  4 ++
 .../include/llvm/Frontend/OpenMP/OMPKinds.def |  1 +
 llvm/lib/IR/Assumptions.cpp   | 13 +++---
 llvm/lib/Transforms/IPO/OpenMPOpt.cpp |  3 +-
 llvm/test/Transforms/OpenMP/icv_tracking.ll   |  2 +
 25 files changed, 157 insertions(+), 67 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 21c1ff25d2862ba..d45e46cab3f923a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -262,6 +262,7 @@ Python Binding Changes
 
 OpenMP Support
 --
+- Added support 'no_openmp_constructs' assumption clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index abdf9333e7125c4..154ecfbaa441820 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2423,6 +2423,28 @@ class OMPNoOpenMPRoutinesClause final
   OMPNoOpenMPRoutinesClause() : OMPNoChildClause() {}
 };
 
+/// This represents the 'no_openmp_constructs' clause in the
+ '#pragma omp assume' directive.
+///
+/// \code
+/// #pragma omp assume no_openmp_constructs
+/// \endcode
+/// In this example directive '#pragma omp assume' has a 'no_openmp_constructs'
+/// clause.
+class OMPNoOpenMPConstructsClause final
+: public OMPNoChildClause {
+public:
+  /// Build 'no_openmp_constructs' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPNoOpenMPConstructsClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPNoChildClause(StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPNoOpenMPConstructsClause() : OMPNoChildClause() {}
+};
+
 /// This represents the 'no_parallelism' clause in the '#pragma omp assume'
 /// directive.
 ///
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 55505794e70542c..06c762c080de09d 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3544,6 +3544,12 @@ bool 
RecursiveASTVisitor::VisitOMPNoOpenMPRoutinesClause(
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPNoOpenMPConstructsClause(
+OMPNoOpenMPConstructsClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPNoParallelismClause(
 OMPNoParallelismClause *) {
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a8b588169725a2c..0ad4c958d098303 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5274,6 +5274,7 @@ optimization passes are aware of the following 
assumptions:
 "omp_no_openmp"
 "omp_no_openmp_routines"
 "omp_no_parallelism"
+"omp_no_openmp_constructs"
 
 The OpenMP standard defines the meaning of OpenMP assumptions ("omp_XYZ" is
 spelled "XYZ" in the `OpenMP 5.1 Standard`_).
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index bbf7a4d95654837..424cab3a7de35cb 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -2073,6 +2073,11 @@ void OMPClausePrinter::VisitOMPNoOpenMPRoutinesClause

[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-09 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/121814

>From c2c2c4c46c3ea615e86484b9f9a14a74fab21295 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 22 Nov 2024 10:35:40 -0600
Subject: [PATCH 1/6] [clang][OpenMP] Add 'align' modifier for 'allocate'
 clause

The 'align' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  92 +++-
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 clang/include/clang/Basic/OpenMPKinds.def |   1 +
 clang/include/clang/Basic/OpenMPKinds.h   |   4 +
 clang/include/clang/Sema/SemaOpenMP.h |  20 +-
 clang/lib/AST/OpenMPClause.cpp|  58 ++-
 clang/lib/Parse/ParseOpenMP.cpp   |  95 +++-
 clang/lib/Sema/SemaOpenMP.cpp | 102 +++--
 clang/lib/Sema/TreeTransform.h|  30 +-
 clang/lib/Serialization/ASTReader.cpp |   6 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 .../allocate_allocator_modifier_codegen.cpp   | 255 ---
 .../allocate_allocator_modifier_messages.cpp  |  97 -
 ...t.cpp => allocate_modifiers_ast_print.cpp} |  77 +++-
 .../OpenMP/allocate_modifiers_codegen.cpp | 409 ++
 .../OpenMP/allocate_modifiers_messages.cpp| 159 +++
 17 files changed, 961 insertions(+), 451 deletions(-)
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp
 rename clang/test/OpenMP/{allocate_allocator_modifier_ast_print.cpp => 
allocate_modifiers_ast_print.cpp} (51%)
 create mode 100644 clang/test/OpenMP/allocate_modifiers_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_modifiers_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index acd9dd9298ce1e..25d390f69bcea3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1284,6 +1284,7 @@ OpenMP Support
 - Changed the OpenMP DeviceRTL to use 'generic' IR. The
   ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
   always build support for AMDGPU and NVPTX targets.
+- Added support for align-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d2f5267e4da5ea..b9088eff3bb52e 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -498,6 +498,9 @@ class OMPAllocateClause final
   /// Allocator specified in the clause, or 'nullptr' if the default one is
   /// used.
   Expr *Allocator = nullptr;
+  /// Alignment specified in the clause, or 'nullptr' if the default one is
+  /// used.
+  Expr *Alignment = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
   /// Modifier of 'allocate' clause.
@@ -505,6 +508,41 @@ class OMPAllocateClause final
   /// Location of allocator modifier if any.
   SourceLocation AllocatorModifierLoc;
 
+  // 

+
+  /// Modifiers for 'allocate' clause.
+  enum { FIRST, SECOND, NUM_MODIFIERS };
+  OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
+
+  /// Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
+
+  /// Set the first allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+
+  /// Set the second allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+
+  /// Set location of the first allocate modifier.
+  void setFirstAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+
+  /// Set location of the second allocate modifier.
+  void setSecondAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+
+  // 

+
   /// Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -514,15 +552,20 @@ class OMPAllocateClause final
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-Expr *Allocator, SourceLocation ColonLoc,
-OpenMPAllocateClauseModifier AllocatorModifier,
-SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
+Expr *Allocator, Expr *Alignment, Sou

[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-10 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/121814

>From d2747bc68455a3dab6ffb47da8851fd1db3f59b5 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 22 Nov 2024 10:35:40 -0600
Subject: [PATCH 1/6] [clang][OpenMP] Add 'align' modifier for 'allocate'
 clause

The 'align' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  92 +++-
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 clang/include/clang/Basic/OpenMPKinds.def |   1 +
 clang/include/clang/Basic/OpenMPKinds.h   |   4 +
 clang/include/clang/Sema/SemaOpenMP.h |  20 +-
 clang/lib/AST/OpenMPClause.cpp|  58 ++-
 clang/lib/Parse/ParseOpenMP.cpp   |  95 +++-
 clang/lib/Sema/SemaOpenMP.cpp | 102 +++--
 clang/lib/Sema/TreeTransform.h|  30 +-
 clang/lib/Serialization/ASTReader.cpp |   6 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 .../allocate_allocator_modifier_codegen.cpp   | 255 ---
 .../allocate_allocator_modifier_messages.cpp  |  97 -
 ...t.cpp => allocate_modifiers_ast_print.cpp} |  77 +++-
 .../OpenMP/allocate_modifiers_codegen.cpp | 409 ++
 .../OpenMP/allocate_modifiers_messages.cpp| 159 +++
 17 files changed, 961 insertions(+), 451 deletions(-)
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp
 rename clang/test/OpenMP/{allocate_allocator_modifier_ast_print.cpp => 
allocate_modifiers_ast_print.cpp} (51%)
 create mode 100644 clang/test/OpenMP/allocate_modifiers_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_modifiers_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5a48d6fbc01fa3..214d11b7975777 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1337,6 +1337,7 @@ OpenMP Support
   always build support for AMDGPU and NVPTX targets.
 - Added support for combined masked constructs  'omp parallel masked taskloop',
   'omp parallel masked taskloop simd','omp masked taskloop' and 'omp masked 
taskloop simd' directive.
+- Added support for align-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d2f5267e4da5ea..b9088eff3bb52e 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -498,6 +498,9 @@ class OMPAllocateClause final
   /// Allocator specified in the clause, or 'nullptr' if the default one is
   /// used.
   Expr *Allocator = nullptr;
+  /// Alignment specified in the clause, or 'nullptr' if the default one is
+  /// used.
+  Expr *Alignment = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
   /// Modifier of 'allocate' clause.
@@ -505,6 +508,41 @@ class OMPAllocateClause final
   /// Location of allocator modifier if any.
   SourceLocation AllocatorModifierLoc;
 
+  // 

+
+  /// Modifiers for 'allocate' clause.
+  enum { FIRST, SECOND, NUM_MODIFIERS };
+  OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
+
+  /// Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
+
+  /// Set the first allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+
+  /// Set the second allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+
+  /// Set location of the first allocate modifier.
+  void setFirstAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+
+  /// Set location of the second allocate modifier.
+  void setSecondAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+
+  // 

+
   /// Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -514,15 +552,20 @@ class OMPAllocateClause final
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-Expr *Allocator, SourceLocation ColonLoc,
-OpenMPAllocateClauseModifier AllocatorModifier,
-SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
+

[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-13 Thread David Pagan via cfe-commits

https://github.com/ddpagan closed 
https://github.com/llvm/llvm-project/pull/121814
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-08 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/121814

>From c2c2c4c46c3ea615e86484b9f9a14a74fab21295 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 22 Nov 2024 10:35:40 -0600
Subject: [PATCH 1/4] [clang][OpenMP] Add 'align' modifier for 'allocate'
 clause

The 'align' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  92 +++-
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 clang/include/clang/Basic/OpenMPKinds.def |   1 +
 clang/include/clang/Basic/OpenMPKinds.h   |   4 +
 clang/include/clang/Sema/SemaOpenMP.h |  20 +-
 clang/lib/AST/OpenMPClause.cpp|  58 ++-
 clang/lib/Parse/ParseOpenMP.cpp   |  95 +++-
 clang/lib/Sema/SemaOpenMP.cpp | 102 +++--
 clang/lib/Sema/TreeTransform.h|  30 +-
 clang/lib/Serialization/ASTReader.cpp |   6 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 .../allocate_allocator_modifier_codegen.cpp   | 255 ---
 .../allocate_allocator_modifier_messages.cpp  |  97 -
 ...t.cpp => allocate_modifiers_ast_print.cpp} |  77 +++-
 .../OpenMP/allocate_modifiers_codegen.cpp | 409 ++
 .../OpenMP/allocate_modifiers_messages.cpp| 159 +++
 17 files changed, 961 insertions(+), 451 deletions(-)
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp
 rename clang/test/OpenMP/{allocate_allocator_modifier_ast_print.cpp => 
allocate_modifiers_ast_print.cpp} (51%)
 create mode 100644 clang/test/OpenMP/allocate_modifiers_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_modifiers_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index acd9dd9298ce1e..25d390f69bcea3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1284,6 +1284,7 @@ OpenMP Support
 - Changed the OpenMP DeviceRTL to use 'generic' IR. The
   ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
   always build support for AMDGPU and NVPTX targets.
+- Added support for align-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d2f5267e4da5ea..b9088eff3bb52e 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -498,6 +498,9 @@ class OMPAllocateClause final
   /// Allocator specified in the clause, or 'nullptr' if the default one is
   /// used.
   Expr *Allocator = nullptr;
+  /// Alignment specified in the clause, or 'nullptr' if the default one is
+  /// used.
+  Expr *Alignment = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
   /// Modifier of 'allocate' clause.
@@ -505,6 +508,41 @@ class OMPAllocateClause final
   /// Location of allocator modifier if any.
   SourceLocation AllocatorModifierLoc;
 
+  // 

+
+  /// Modifiers for 'allocate' clause.
+  enum { FIRST, SECOND, NUM_MODIFIERS };
+  OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
+
+  /// Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
+
+  /// Set the first allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+
+  /// Set the second allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+
+  /// Set location of the first allocate modifier.
+  void setFirstAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+
+  /// Set location of the second allocate modifier.
+  void setSecondAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+
+  // 

+
   /// Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -514,15 +552,20 @@ class OMPAllocateClause final
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-Expr *Allocator, SourceLocation ColonLoc,
-OpenMPAllocateClauseModifier AllocatorModifier,
-SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
+Expr *Allocator, Expr *Alignment, Sou

[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-08 Thread David Pagan via cfe-commits

ddpagan wrote:

Made changes requested by Alexey.

https://github.com/llvm/llvm-project/pull/121814
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][OpenMP] Add 'align' modifier for 'allocate' clause (PR #121814)

2025-01-09 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/121814

>From c2c2c4c46c3ea615e86484b9f9a14a74fab21295 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 22 Nov 2024 10:35:40 -0600
Subject: [PATCH 1/5] [clang][OpenMP] Add 'align' modifier for 'allocate'
 clause

The 'align' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/include/clang/AST/OpenMPClause.h|  92 +++-
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 clang/include/clang/Basic/OpenMPKinds.def |   1 +
 clang/include/clang/Basic/OpenMPKinds.h   |   4 +
 clang/include/clang/Sema/SemaOpenMP.h |  20 +-
 clang/lib/AST/OpenMPClause.cpp|  58 ++-
 clang/lib/Parse/ParseOpenMP.cpp   |  95 +++-
 clang/lib/Sema/SemaOpenMP.cpp | 102 +++--
 clang/lib/Sema/TreeTransform.h|  30 +-
 clang/lib/Serialization/ASTReader.cpp |   6 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 .../allocate_allocator_modifier_codegen.cpp   | 255 ---
 .../allocate_allocator_modifier_messages.cpp  |  97 -
 ...t.cpp => allocate_modifiers_ast_print.cpp} |  77 +++-
 .../OpenMP/allocate_modifiers_codegen.cpp | 409 ++
 .../OpenMP/allocate_modifiers_messages.cpp| 159 +++
 17 files changed, 961 insertions(+), 451 deletions(-)
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_codegen.cpp
 delete mode 100644 clang/test/OpenMP/allocate_allocator_modifier_messages.cpp
 rename clang/test/OpenMP/{allocate_allocator_modifier_ast_print.cpp => 
allocate_modifiers_ast_print.cpp} (51%)
 create mode 100644 clang/test/OpenMP/allocate_modifiers_codegen.cpp
 create mode 100644 clang/test/OpenMP/allocate_modifiers_messages.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index acd9dd9298ce1e..25d390f69bcea3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1284,6 +1284,7 @@ OpenMP Support
 - Changed the OpenMP DeviceRTL to use 'generic' IR. The
   ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
   always build support for AMDGPU and NVPTX targets.
+- Added support for align-modifier in 'allocate' clause.
 
 Improvements
 
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d2f5267e4da5ea..b9088eff3bb52e 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -498,6 +498,9 @@ class OMPAllocateClause final
   /// Allocator specified in the clause, or 'nullptr' if the default one is
   /// used.
   Expr *Allocator = nullptr;
+  /// Alignment specified in the clause, or 'nullptr' if the default one is
+  /// used.
+  Expr *Alignment = nullptr;
   /// Position of the ':' delimiter in the clause;
   SourceLocation ColonLoc;
   /// Modifier of 'allocate' clause.
@@ -505,6 +508,41 @@ class OMPAllocateClause final
   /// Location of allocator modifier if any.
   SourceLocation AllocatorModifierLoc;
 
+  // 

+
+  /// Modifiers for 'allocate' clause.
+  enum { FIRST, SECOND, NUM_MODIFIERS };
+  OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
+
+  /// Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
+
+  /// Set the first allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+
+  /// Set the second allocate modifier.
+  ///
+  /// \param M Allocate modifier.
+  void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+
+  /// Set location of the first allocate modifier.
+  void setFirstAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+
+  /// Set location of the second allocate modifier.
+  void setSecondAllocateModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+
+  // 

+
   /// Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -514,15 +552,20 @@ class OMPAllocateClause final
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-Expr *Allocator, SourceLocation ColonLoc,
-OpenMPAllocateClauseModifier AllocatorModifier,
-SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
+Expr *Allocator, Expr *Alignment, Sou