[PATCH] D158266: [OpenMP] Patch for Support to loop bind clause : Checking Parent Region

2023-11-07 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

Is there a github PR associated with this? If yes, what is the PR? If not, one 
should be created that includes a fix for the teams loop/loop error issue. 
Please add me as a reviewer. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158266/new/

https://reviews.llvm.org/D158266

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


[PATCH] D158266: [OpenMP] Patch for Support to loop bind clause : Checking Parent Region

2023-10-27 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

Ok. Thanks for the clarification.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158266/new/

https://reviews.llvm.org/D158266

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


[PATCH] D158266: [OpenMP] Patch for Support to loop bind clause : Checking Parent Region

2023-10-27 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

Did anything change after the patch was reverted?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158266/new/

https://reviews.llvm.org/D158266

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-09-02 Thread David Pagan via Phabricator via cfe-commits
ddpagan abandoned this revision.
ddpagan added a comment.

Change no longer needed per review/comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-12 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1570-1575
+  // If we are here with a 'target teams loop' then we are emitting the
+  // 'parallel' region of the 'target teams distribute parallel for'
+  // emitted in place of the 'target teams loop'. Based on the specification
+  // noted above, an if-clause associated with a 'target teams loop', be it
+  // 'if(val)' or an 'if(target:val)', will apply only to 'target' and not
+  // the 'parallel' of the 'target teams distribute parallel for'.

ABataev wrote:
> ddpagan wrote:
> > ABataev wrote:
> > > ddpagan wrote:
> > > > ABataev wrote:
> > > > > ddpagan wrote:
> > > > > > ABataev wrote:
> > > > > > > It does not match the spec. 
> > > > > > > ```
> > > > > > > For a combined or composite construct, if no 
> > > > > > > directive-name-modifier is specified then the if clause applies 
> > > > > > > to all constituent constructs to which an if clause can apply.
> > > > > > > ```
> > > > > > > So, if(val) should be applied to both target and parallel 
> > > > > > > regions, no?
> > > > > > > It does not match the spec. 
> > > > > > > ```
> > > > > > > For a combined or composite construct, if no 
> > > > > > > directive-name-modifier is specified then the if clause applies 
> > > > > > > to all constituent constructs to which an if clause can apply.
> > > > > > > ```
> > > > > > > So, if(val) should be applied to both target and parallel 
> > > > > > > regions, no?
> > > > > > 
> > > > > > Hi Alexey - Question for you: does revising the comment above at 
> > > > > > lines 1570-1575 to the following text help explain in a better way 
> > > > > > what's being done, and why?
> > > > > > 
> > > > > >   If we are handling a 'target teams distribute parallel for' 
> > > > > > explicitly written
> > > > > >   in the source, and it has an 'if(val)' clause, the if condition 
> > > > > > is applied to
> > > > > >   both 'target' and 'parallel' regions according to
> > > > > >   OpenMP 5.2 [3.4, if Clause, Semantics, 15-18].
> > > > > > 
> > > > > >   However, if we are mapping an explicit 'target teams loop 
> > > > > > if(val)' onto a
> > > > > >   'target teams distribute parallel for if(val)', to preserve the 
> > > > > > 'if' semantics
> > > > > >   as specified by the user with the 'target teams loop', we apply 
> > > > > > it just to
> > > > > >   the 'target' region.
> > > > > It does not match the spec. Why we shall handle it this way?
> > > > You're right, Alexey ... it doesn't match the spec, but here's why we 
> > > > thought this would be an appropriate way to implement 'target teams 
> > > > loop if(val)'. When a user specifies 'if(val)' with a 'target teams 
> > > > loop', their expectation is that its effect will only apply to the 
> > > > 'target' region. Since a 'loop' construct can be implemented in a 
> > > > number of different ways with the freedom granted by the specs 
> > > > description of 'loop' (part of which describes it as being able to be 
> > > > run concurrently), using a 'target teams distribute parallel for' 
> > > > construct is a simple and effective default choice, which is what 
> > > > happens today. 
> > > > target_teams_loop => target_teams_distribute_parallel_for
> > > > Applying the if clause to the parallel region for this case can 
> > > > potentially limit it to one thread, which would hinder performance 
> > > > gains otherwise possible, and presumably wouldn't be what the user 
> > > > wanted/expected.
> > > > 
> > > > The semantics of the spec (OpenMP 5.2 [3.4, if Clause, Semantics, 
> > > > 15-18]) is definitely what should be applied to an explicit instance of 
> > > > target_teams_distribute_parallel_for, but in this case (when mapping 
> > > > target_teams_loop => target_teams_distribute_parallel_for) it seems 
> > > > reasonable to make the choice described above.
> > > I'm not sure this is true users  expectations.
> > You're right in the sense that there is an assumption being made there. So 
> > would you recommend just staying with the semantics as defined in the spec 
> > regardless?
> Yew, better to follow spec defaults.
Ok. Sounds good. Thanks for review and suggestions, Alexey.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-12 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1570-1575
+  // If we are here with a 'target teams loop' then we are emitting the
+  // 'parallel' region of the 'target teams distribute parallel for'
+  // emitted in place of the 'target teams loop'. Based on the specification
+  // noted above, an if-clause associated with a 'target teams loop', be it
+  // 'if(val)' or an 'if(target:val)', will apply only to 'target' and not
+  // the 'parallel' of the 'target teams distribute parallel for'.

ABataev wrote:
> ddpagan wrote:
> > ABataev wrote:
> > > ddpagan wrote:
> > > > ABataev wrote:
> > > > > It does not match the spec. 
> > > > > ```
> > > > > For a combined or composite construct, if no directive-name-modifier 
> > > > > is specified then the if clause applies to all constituent constructs 
> > > > > to which an if clause can apply.
> > > > > ```
> > > > > So, if(val) should be applied to both target and parallel regions, no?
> > > > > It does not match the spec. 
> > > > > ```
> > > > > For a combined or composite construct, if no directive-name-modifier 
> > > > > is specified then the if clause applies to all constituent constructs 
> > > > > to which an if clause can apply.
> > > > > ```
> > > > > So, if(val) should be applied to both target and parallel regions, no?
> > > > 
> > > > Hi Alexey - Question for you: does revising the comment above at lines 
> > > > 1570-1575 to the following text help explain in a better way what's 
> > > > being done, and why?
> > > > 
> > > >   If we are handling a 'target teams distribute parallel for' 
> > > > explicitly written
> > > >   in the source, and it has an 'if(val)' clause, the if condition is 
> > > > applied to
> > > >   both 'target' and 'parallel' regions according to
> > > >   OpenMP 5.2 [3.4, if Clause, Semantics, 15-18].
> > > > 
> > > >   However, if we are mapping an explicit 'target teams loop if(val)' 
> > > > onto a
> > > >   'target teams distribute parallel for if(val)', to preserve the 'if' 
> > > > semantics
> > > >   as specified by the user with the 'target teams loop', we apply it 
> > > > just to
> > > >   the 'target' region.
> > > It does not match the spec. Why we shall handle it this way?
> > You're right, Alexey ... it doesn't match the spec, but here's why we 
> > thought this would be an appropriate way to implement 'target teams loop 
> > if(val)'. When a user specifies 'if(val)' with a 'target teams loop', their 
> > expectation is that its effect will only apply to the 'target' region. 
> > Since a 'loop' construct can be implemented in a number of different ways 
> > with the freedom granted by the specs description of 'loop' (part of which 
> > describes it as being able to be run concurrently), using a 'target teams 
> > distribute parallel for' construct is a simple and effective default 
> > choice, which is what happens today. 
> > target_teams_loop => target_teams_distribute_parallel_for
> > Applying the if clause to the parallel region for this case can potentially 
> > limit it to one thread, which would hinder performance gains otherwise 
> > possible, and presumably wouldn't be what the user wanted/expected.
> > 
> > The semantics of the spec (OpenMP 5.2 [3.4, if Clause, Semantics, 15-18]) 
> > is definitely what should be applied to an explicit instance of 
> > target_teams_distribute_parallel_for, but in this case (when mapping 
> > target_teams_loop => target_teams_distribute_parallel_for) it seems 
> > reasonable to make the choice described above.
> I'm not sure this is true users  expectations.
You're right in the sense that there is an assumption being made there. So 
would you recommend just staying with the semantics as defined in the spec 
regardless?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-12 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1570-1575
+  // If we are here with a 'target teams loop' then we are emitting the
+  // 'parallel' region of the 'target teams distribute parallel for'
+  // emitted in place of the 'target teams loop'. Based on the specification
+  // noted above, an if-clause associated with a 'target teams loop', be it
+  // 'if(val)' or an 'if(target:val)', will apply only to 'target' and not
+  // the 'parallel' of the 'target teams distribute parallel for'.

ABataev wrote:
> ddpagan wrote:
> > ABataev wrote:
> > > It does not match the spec. 
> > > ```
> > > For a combined or composite construct, if no directive-name-modifier is 
> > > specified then the if clause applies to all constituent constructs to 
> > > which an if clause can apply.
> > > ```
> > > So, if(val) should be applied to both target and parallel regions, no?
> > > It does not match the spec. 
> > > ```
> > > For a combined or composite construct, if no directive-name-modifier is 
> > > specified then the if clause applies to all constituent constructs to 
> > > which an if clause can apply.
> > > ```
> > > So, if(val) should be applied to both target and parallel regions, no?
> > 
> > Hi Alexey - Question for you: does revising the comment above at lines 
> > 1570-1575 to the following text help explain in a better way what's being 
> > done, and why?
> > 
> >   If we are handling a 'target teams distribute parallel for' explicitly 
> > written
> >   in the source, and it has an 'if(val)' clause, the if condition is 
> > applied to
> >   both 'target' and 'parallel' regions according to
> >   OpenMP 5.2 [3.4, if Clause, Semantics, 15-18].
> > 
> >   However, if we are mapping an explicit 'target teams loop if(val)' onto a
> >   'target teams distribute parallel for if(val)', to preserve the 'if' 
> > semantics
> >   as specified by the user with the 'target teams loop', we apply it just to
> >   the 'target' region.
> It does not match the spec. Why we shall handle it this way?
You're right, Alexey ... it doesn't match the spec, but here's why we thought 
this would be an appropriate way to implement 'target teams loop if(val)'. When 
a user specifies 'if(val)' with a 'target teams loop', their expectation is 
that its effect will only apply to the 'target' region. Since a 'loop' 
construct can be implemented in a number of different ways with the freedom 
granted by the specs description of 'loop' (part of which describes it as being 
able to be run concurrently), using a 'target teams distribute parallel for' 
construct is a simple and effective default choice, which is what happens 
today. 
target_teams_loop => target_teams_distribute_parallel_for
Applying the if clause to the parallel region for this case can potentially 
limit it to one thread, which would hinder performance gains otherwise 
possible, and presumably wouldn't be what the user wanted/expected.

The semantics of the spec (OpenMP 5.2 [3.4, if Clause, Semantics, 15-18]) is 
definitely what should be applied to an explicit instance of 
target_teams_distribute_parallel_for, but in this case (when mapping 
target_teams_loop => target_teams_distribute_parallel_for) it seems reasonable 
to make the choice described above.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-11 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1570-1575
+  // If we are here with a 'target teams loop' then we are emitting the
+  // 'parallel' region of the 'target teams distribute parallel for'
+  // emitted in place of the 'target teams loop'. Based on the specification
+  // noted above, an if-clause associated with a 'target teams loop', be it
+  // 'if(val)' or an 'if(target:val)', will apply only to 'target' and not
+  // the 'parallel' of the 'target teams distribute parallel for'.

ABataev wrote:
> It does not match the spec. 
> ```
> For a combined or composite construct, if no directive-name-modifier is 
> specified then the if clause applies to all constituent constructs to which 
> an if clause can apply.
> ```
> So, if(val) should be applied to both target and parallel regions, no?
> It does not match the spec. 
> ```
> For a combined or composite construct, if no directive-name-modifier is 
> specified then the if clause applies to all constituent constructs to which 
> an if clause can apply.
> ```
> So, if(val) should be applied to both target and parallel regions, no?

Hi Alexey - Question for you: does revising the comment above at lines 
1570-1575 to the following text help explain in a better way what's being done, 
and why?

  If we are handling a 'target teams distribute parallel for' explicitly written
  in the source, and it has an 'if(val)' clause, the if condition is applied to
  both 'target' and 'parallel' regions according to
  OpenMP 5.2 [3.4, if Clause, Semantics, 15-18].

  However, if we are mapping an explicit 'target teams loop if(val)' onto a
  'target teams distribute parallel for if(val)', to preserve the 'if' semantics
  as specified by the user with the 'target teams loop', we apply it just to
  the 'target' region.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

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


[PATCH] D157135: [OpenMP][Docs] Update OpenMP supported features table

2023-08-07 Thread David Pagan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6204724df56: [OpenMP][Docs] Update OpenMP supported 
features table (authored by ddpagan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157135/new/

https://reviews.llvm.org/D157135

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -309,7 +309,7 @@
 
+--+--+--+---+
 | loop | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :part:`partial`  | D127855   
|
 
+--+--+--+---+
-| memory management| alignment for allocate directive and clause   
   | :part:`worked on`| 
  |
+| memory management| alignment for allocate directive and clause   
   | :good:`done` | D115683 
  |
 
+--+--+--+---+
 | memory management| new memory management routines
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -309,7 +309,7 @@
 +--+--+--+---+
 | loop | 'reproducible'/'unconstrained' modifiers in 'order' clause   | :part:`partial`  | D127855   |
 +--+--+--+---+
-| memory management| alignment for allocate directive and clause  | :part:`worked on`|   |
+| memory management| alignment for allocate directive and clause  | :good:`done` | D115683   |
 +--+--+--+---+
 | memory management| new memory management routines   | :none:`unclaimed`|   |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-07 Thread David Pagan via Phabricator via cfe-commits
ddpagan updated this revision to Diff 547982.
ddpagan added a comment.

As requested, added reference to OpenMP 5.2 specification that discusses 
handling of if clauses with combined/composite directives. Also, improved 
comment relating to what was being done and why.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp

Index: clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
@@ -695,7 +695,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i32 0, ptr [[DOTOMP_COMB_LB]], align 4
@@ -729,16 +728,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP11:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined(ptr [[TMP11]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
+// CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_INC:%.*]]
 // CHECK1:   omp.inner.for.inc:
-// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
-// CHECK1-NEXT:[[TMP13:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
-// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP12]], [[TMP13]]
+// CHECK1-NEXT:[[TMP11:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
+// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
+// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP11]], [[TMP12]]
 // CHECK1-NEXT:store i32 [[ADD]], ptr [[DOTOMP_IV]], align 4
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_COND]]
 // CHECK1:   omp.inner.for.end:
@@ -847,7 +842,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i64 [[DOTCAPTURE_EXPR_]], ptr [[DOTCAPTURE_EXPR__ADDR]], align 8
@@ -882,25 +876,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:[[TMP11:%.*]] = load i8, ptr [[DOTCAPTURE_EXPR__ADDR]], align 1
-// CHECK1-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP11]] to i1
-// CHECK1-NEXT:br i1 [[TOBOOL]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_ELSE:%.*]]
-// CHECK1:   omp_if.then:
 // CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
-// CHECK1-NEXT:br label [[OMP_IF_END:%.*]]
-// CHECK1:   omp_if.else:
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP12:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined(ptr [[TMP12]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:br label [[OMP_IF_END]]
-// CHECK1:   omp_if.end:
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_INC:%.*]]
 // CHECK1:   omp.inner.for.inc:
-// CHECK1-NEXT:[[TMP13:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
-// CHECK1-NEXT:[[TMP14:%.*]] = load i32, ptr [[DOTOMP_STRI

[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-05 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1564
+  // Any if-clause associated with expansion for 'target teams loop' should
+  // apply to target region only. OpenMP 5.2 [3.4, if Clause, Semantics, 15-18]
+  if (S.getDirectiveKind() != OMPD_target_teams_loop)

ABataev wrote:
> I don't see this statement in the standard
Sorry for that confusion on my part, Alexey. You're correct. I'll change this 
to the proper spec phrasing and resubmit.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-05 Thread David Pagan via Phabricator via cfe-commits
ddpagan updated this revision to Diff 547515.
ddpagan added a comment.

Added reference to relevant portion of the OpenMP 5.2 specification.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157197/new/

https://reviews.llvm.org/D157197

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp

Index: clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
@@ -695,7 +695,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i32 0, ptr [[DOTOMP_COMB_LB]], align 4
@@ -729,16 +728,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP11:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined(ptr [[TMP11]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
+// CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_INC:%.*]]
 // CHECK1:   omp.inner.for.inc:
-// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
-// CHECK1-NEXT:[[TMP13:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
-// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP12]], [[TMP13]]
+// CHECK1-NEXT:[[TMP11:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
+// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
+// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP11]], [[TMP12]]
 // CHECK1-NEXT:store i32 [[ADD]], ptr [[DOTOMP_IV]], align 4
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_COND]]
 // CHECK1:   omp.inner.for.end:
@@ -847,7 +842,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i64 [[DOTCAPTURE_EXPR_]], ptr [[DOTCAPTURE_EXPR__ADDR]], align 8
@@ -882,25 +876,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:[[TMP11:%.*]] = load i8, ptr [[DOTCAPTURE_EXPR__ADDR]], align 1
-// CHECK1-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP11]] to i1
-// CHECK1-NEXT:br i1 [[TOBOOL]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_ELSE:%.*]]
-// CHECK1:   omp_if.then:
 // CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
-// CHECK1-NEXT:br label [[OMP_IF_END:%.*]]
-// CHECK1:   omp_if.else:
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP12:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined(ptr [[TMP12]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:br label [[OMP_IF_END]]
-// CHECK1:   omp_if.end:
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_INC:%.*]]
 // CHECK1:   omp.inner.for.inc:
-// CHECK1-NEXT:[[TMP13:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
-// CHECK1-NEXT:[[TMP14:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
-// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP13]], [[TMP14]]
+// CHECK1-NEXT:[[TMP11:%.*]] = load i32, pt

[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-08-05 Thread David Pagan via Phabricator via cfe-commits
ddpagan created this revision.
ddpagan added a reviewer: ABataev.
ddpagan added projects: clang, OpenMP.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
ddpagan requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.

When emitting parallel region for 'target teams distribute parallel for' 
expansion of 'target teams loop', ignore if-clause as anything specified
should apply to target region only.

Updated test results for OpenMP/target_teams_generic_loop_if_codegen.cpp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157197

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp

Index: clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
@@ -695,7 +695,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i32 0, ptr [[DOTOMP_COMB_LB]], align 4
@@ -729,16 +728,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP11:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined(ptr [[TMP11]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
+// CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_INC:%.*]]
 // CHECK1:   omp.inner.for.inc:
-// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
-// CHECK1-NEXT:[[TMP13:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
-// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP12]], [[TMP13]]
+// CHECK1-NEXT:[[TMP11:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
+// CHECK1-NEXT:[[TMP12:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
+// CHECK1-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP11]], [[TMP12]]
 // CHECK1-NEXT:store i32 [[ADD]], ptr [[DOTOMP_IV]], align 4
 // CHECK1-NEXT:br label [[OMP_INNER_FOR_COND]]
 // CHECK1:   omp.inner.for.end:
@@ -847,7 +842,6 @@
 // CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
 // CHECK1-NEXT:store i64 [[DOTCAPTURE_EXPR_]], ptr [[DOTCAPTURE_EXPR__ADDR]], align 8
@@ -882,25 +876,12 @@
 // CHECK1-NEXT:[[TMP8:%.*]] = zext i32 [[TMP7]] to i64
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
 // CHECK1-NEXT:[[TMP10:%.*]] = zext i32 [[TMP9]] to i64
-// CHECK1-NEXT:[[TMP11:%.*]] = load i8, ptr [[DOTCAPTURE_EXPR__ADDR]], align 1
-// CHECK1-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP11]] to i1
-// CHECK1-NEXT:br i1 [[TOBOOL]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_ELSE:%.*]]
-// CHECK1:   omp_if.then:
 // CHECK1-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB3]], i32 2, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined, i64 [[TMP8]], i64 [[TMP10]])
-// CHECK1-NEXT:br label [[OMP_IF_END:%.*]]
-// CHECK1:   omp_if.else:
-// CHECK1-NEXT:call void @__kmpc_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:[[TMP12:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store i32 0, ptr [[DOTBOUND_ZERO_ADDR]], align 4
-// CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l90.omp_outlined.omp_outlined(ptr [[TMP12]], ptr [[DOTBOUND_ZERO_ADDR]], i64 [[TMP8]], i64 [[TMP10]]) #[[ATTR2]]
-// CHECK1-NEXT:call void @__kmpc_end_serialized_parallel(ptr @[[GLOB3]], i32 [[TMP1]])
-// CHECK1-NEXT:br label

[PATCH] D157140: [clang][Sema][OpenMP] Fix capture region for 'target teams loop'

2023-08-04 Thread David Pagan via Phabricator via cfe-commits
ddpagan created this revision.
ddpagan added a reviewer: ABataev.
ddpagan added projects: clang, OpenMP.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
ddpagan requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.

The capture region for 'target teams loop' should be the same as that for 
'target teams distribute parallel for' with an 'if(target:val)'. For this
specific case, there should be no capture region.

Updated test results for OpenMP/target_teams_generic_loop_if_codegen.cpp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157140

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp

Index: clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
@@ -428,13 +428,8 @@
 // CHECK1-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[TMP:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[KERNEL_ARGS:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS:%.*]], align 8
-// CHECK1-NEXT:[[DOTCAPTURE_EXPR_:%.*]] = alloca i8, align 1
-// CHECK1-NEXT:[[DOTCAPTURE_EXPR__CASTED:%.*]] = alloca i64, align 8
-// CHECK1-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [1 x ptr], align 8
-// CHECK1-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [1 x ptr], align 8
-// CHECK1-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [1 x ptr], align 8
-// CHECK1-NEXT:[[_TMP5:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[KERNEL_ARGS6:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS]], align 8
+// CHECK1-NEXT:[[_TMP2:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[KERNEL_ARGS3:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS]], align 8
 // CHECK1-NEXT:store i32 0, ptr [[RETVAL]], align 4
 // CHECK1-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS]], i32 0, i32 0
 // CHECK1-NEXT:store i32 2, ptr [[TMP0]], align 4
@@ -472,69 +467,52 @@
 // CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l83() #[[ATTR2]]
 // CHECK1-NEXT:[[TMP15:%.*]] = load i32, ptr @Arg, align 4
 // CHECK1-NEXT:[[TOBOOL:%.*]] = icmp ne i32 [[TMP15]], 0
-// CHECK1-NEXT:[[FROMBOOL:%.*]] = zext i1 [[TOBOOL]] to i8
-// CHECK1-NEXT:store i8 [[FROMBOOL]], ptr [[DOTCAPTURE_EXPR_]], align 1
-// CHECK1-NEXT:[[TMP16:%.*]] = load i8, ptr [[DOTCAPTURE_EXPR_]], align 1
-// CHECK1-NEXT:[[TOBOOL1:%.*]] = trunc i8 [[TMP16]] to i1
-// CHECK1-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TOBOOL1]] to i8
-// CHECK1-NEXT:store i8 [[FROMBOOL2]], ptr [[DOTCAPTURE_EXPR__CASTED]], align 1
-// CHECK1-NEXT:[[TMP17:%.*]] = load i64, ptr [[DOTCAPTURE_EXPR__CASTED]], align 8
-// CHECK1-NEXT:[[TMP18:%.*]] = load i8, ptr [[DOTCAPTURE_EXPR_]], align 1
-// CHECK1-NEXT:[[TOBOOL3:%.*]] = trunc i8 [[TMP18]] to i1
-// CHECK1-NEXT:br i1 [[TOBOOL3]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_ELSE:%.*]]
+// CHECK1-NEXT:br i1 [[TOBOOL]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_ELSE:%.*]]
 // CHECK1:   omp_if.then:
-// CHECK1-NEXT:[[TMP19:%.*]] = getelementptr inbounds [1 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
-// CHECK1-NEXT:store i64 [[TMP17]], ptr [[TMP19]], align 8
-// CHECK1-NEXT:[[TMP20:%.*]] = getelementptr inbounds [1 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 0
-// CHECK1-NEXT:store i64 [[TMP17]], ptr [[TMP20]], align 8
-// CHECK1-NEXT:[[TMP21:%.*]] = getelementptr inbounds [1 x ptr], ptr [[DOTOFFLOAD_MAPPERS]], i64 0, i64 0
+// CHECK1-NEXT:[[TMP16:%.*]] = load i32, ptr @Arg, align 4
+// CHECK1-NEXT:[[TOBOOL1:%.*]] = icmp ne i32 [[TMP16]], 0
+// CHECK1-NEXT:[[TMP17:%.*]] = select i1 [[TOBOOL1]], i32 0, i32 1
+// CHECK1-NEXT:[[TMP18:%.*]] = insertvalue [3 x i32] zeroinitializer, i32 [[TMP17]], 0
+// CHECK1-NEXT:[[TMP19:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS3]], i32 0, i32 0
+// CHECK1-NEXT:store i32 2, ptr [[TMP19]], align 4
+// CHECK1-NEXT:[[TMP20:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS3]], i32 0, i32 1
+// CHECK1-NEXT:store i32 0, ptr [[TMP20]], align 4
+// CHECK1-NEXT:[[TMP21:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS3]], i32 0, i32 2
 // CHECK1-NEXT:store ptr null, ptr [[TMP21]], align 8
-// CHECK1-NEXT:[[TMP22:%.*]] = getelementptr inbounds [1 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
-// CHECK1-NEXT:[[TMP23:%.*]] = getelementptr inbounds [1 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 0
-// CHECK1-NEXT:[[TMP24:%.*]] = load i8, ptr [[DOTCAPTURE_EXPR_]], align 1
-// CHECK1-NEXT:[[TOBOOL4:%.*]] = trunc i8 [[TMP24]] to i1
-// CHECK1-NEXT:[[TMP25:%.*]] = select i1 [[TOBOOL4]],

[PATCH] D157135: [OpenMP][Docs] Update OpenMP supported features table

2023-08-04 Thread David Pagan via Phabricator via cfe-commits
ddpagan created this revision.
ddpagan added a reviewer: ABataev.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
ddpagan requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

Updated status of alignment clause for allocate directive in OpenMP features 
table, section OpenMP 5.1 Implementation Details.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157135

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -309,7 +309,7 @@
 
+--+--+--+---+
 | loop | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :part:`partial`  | D127855   
|
 
+--+--+--+---+
-| memory management| alignment for allocate directive and clause   
   | :part:`worked on`| 
  |
+| memory management| alignment for allocate directive and clause   
   | :good:`done` | D115683 
  |
 
+--+--+--+---+
 | memory management| new memory management routines
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -309,7 +309,7 @@
 +--+--+--+---+
 | loop | 'reproducible'/'unconstrained' modifiers in 'order' clause   | :part:`partial`  | D127855   |
 +--+--+--+---+
-| memory management| alignment for allocate directive and clause  | :part:`worked on`|   |
+| memory management| alignment for allocate directive and clause  | :good:`done` | D115683   |
 +--+--+--+---+
 | memory management| new memory management routines   | :none:`unclaimed`|   |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156352: [OpenMP][Sema] Fix directive name modifier/if-clause/'target teams loop'

2023-07-26 Thread David Pagan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7cb9698374ac: [OpenMP][Sema] Fix directive name 
modifier/if-clause/'target teams loop' (authored by ddpagan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156352/new/

https://reviews.llvm.org/D156352

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_messages.cpp

Index: clang/test/OpenMP/target_teams_generic_loop_messages.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_messages.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_messages.cpp
@@ -127,6 +127,16 @@
   for (i=0; i<1000; ++i)
 z = i+11;
 
+  // expected-error@+1 {{directive name modifier 'teams' is not allowed for '#pragma omp target teams loop'}}
+  #pragma omp target teams loop if(teams:1)
+  for (i=0; i<1000; ++i)
+z = i+11;
+
+  // expected-error@+1 {{directive name modifier 'parallel' is not allowed for '#pragma omp target teams loop'}}
+  #pragma omp target teams loop if(parallel:0)
+  for (i=0; i<1000; ++i)
+z = i+11;
+
 }
 
 template 
Index: clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
@@ -48,7 +48,7 @@
 #pragma omp target teams loop
   for(int i = 0 ; i < 100; i++) {}
 
-#pragma omp target teams loop if (parallel: false)
+#pragma omp target teams loop if (target: false)
   for(int i = 0 ; i < 100; i++) {
 gtid_test();
   }
@@ -65,7 +65,7 @@
   for(int i = 0 ; i < 100; i++) {
 fn2();
   }
-#pragma omp target teams loop if (parallel: Arg)
+#pragma omp target teams loop if (target: Arg)
   for(int i = 0 ; i < 100; i++) {
 fn3();
   }
@@ -110,8 +110,6 @@
 // CHECK1-NEXT:  entry:
 // CHECK1-NEXT:[[TMP:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[KERNEL_ARGS:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS:%.*]], align 8
-// CHECK1-NEXT:[[_TMP1:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[KERNEL_ARGS2:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS]], align 8
 // CHECK1-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS]], i32 0, i32 0
 // CHECK1-NEXT:store i32 2, ptr [[TMP0]], align 4
 // CHECK1-NEXT:[[TMP1:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS]], i32 0, i32 1
@@ -145,39 +143,7 @@
 // CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}__Z9gtid_testv_l48() #[[ATTR2:[0-9]+]]
 // CHECK1-NEXT:br label [[OMP_OFFLOAD_CONT]]
 // CHECK1:   omp_offload.cont:
-// CHECK1-NEXT:[[TMP15:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 0
-// CHECK1-NEXT:store i32 2, ptr [[TMP15]], align 4
-// CHECK1-NEXT:[[TMP16:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 1
-// CHECK1-NEXT:store i32 0, ptr [[TMP16]], align 4
-// CHECK1-NEXT:[[TMP17:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 2
-// CHECK1-NEXT:store ptr null, ptr [[TMP17]], align 8
-// CHECK1-NEXT:[[TMP18:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 3
-// CHECK1-NEXT:store ptr null, ptr [[TMP18]], align 8
-// CHECK1-NEXT:[[TMP19:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 4
-// CHECK1-NEXT:store ptr null, ptr [[TMP19]], align 8
-// CHECK1-NEXT:[[TMP20:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 5
-// CHECK1-NEXT:store ptr null, ptr [[TMP20]], align 8
-// CHECK1-NEXT:[[TMP21:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 6
-// CHECK1-NEXT:store ptr null, ptr [[TMP21]], align 8
-// CHECK1-NEXT:[[TMP22:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 7
-// CHECK1-NEXT:store ptr null, ptr [[TMP22]], align 8
-// CHECK1-NEXT:[[TMP23:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 8
-// CHECK1-NEXT:store i64 100, ptr [[TMP23]], align 8
-// CHECK1-NEXT:[[TMP24:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 9
-// CHECK1-NEXT:store i64 0, ptr [[TMP24]], align 8
-// CHECK1-NEXT:[[TMP25:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 10
-// CHECK1-NEXT:store [3 x i32] zeroinitializer, ptr [[TMP25]], align 4
-// CHECK1-NEXT:[[TMP26

[PATCH] D156352: [OpenMP][Sema] Fix directive name modifier/if-clause/'target teams loop'

2023-07-26 Thread David Pagan via Phabricator via cfe-commits
ddpagan created this revision.
ddpagan added reviewers: ABataev, jdoerfert, ronlieb.
ddpagan added projects: OpenMP, clang.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
ddpagan requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.

The if-clause on 'target teams loop' should only accept "target" as a directive 
name modifier. Any other directive name should generate an error.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156352

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_messages.cpp

Index: clang/test/OpenMP/target_teams_generic_loop_messages.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_messages.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_messages.cpp
@@ -127,6 +127,16 @@
   for (i=0; i<1000; ++i)
 z = i+11;
 
+  // expected-error@+1 {{directive name modifier 'teams' is not allowed for '#pragma omp target teams loop'}}
+  #pragma omp target teams loop if(teams:1)
+  for (i=0; i<1000; ++i)
+z = i+11;
+
+  // expected-error@+1 {{directive name modifier 'parallel' is not allowed for '#pragma omp target teams loop'}}
+  #pragma omp target teams loop if(parallel:0)
+  for (i=0; i<1000; ++i)
+z = i+11;
+
 }
 
 template 
Index: clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
===
--- clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
+++ clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
@@ -48,7 +48,7 @@
 #pragma omp target teams loop
   for(int i = 0 ; i < 100; i++) {}
 
-#pragma omp target teams loop if (parallel: false)
+#pragma omp target teams loop if (target: false)
   for(int i = 0 ; i < 100; i++) {
 gtid_test();
   }
@@ -65,7 +65,7 @@
   for(int i = 0 ; i < 100; i++) {
 fn2();
   }
-#pragma omp target teams loop if (parallel: Arg)
+#pragma omp target teams loop if (target: Arg)
   for(int i = 0 ; i < 100; i++) {
 fn3();
   }
@@ -110,8 +110,6 @@
 // CHECK1-NEXT:  entry:
 // CHECK1-NEXT:[[TMP:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[KERNEL_ARGS:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS:%.*]], align 8
-// CHECK1-NEXT:[[_TMP1:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[KERNEL_ARGS2:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS]], align 8
 // CHECK1-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS]], i32 0, i32 0
 // CHECK1-NEXT:store i32 2, ptr [[TMP0]], align 4
 // CHECK1-NEXT:[[TMP1:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS]], i32 0, i32 1
@@ -145,39 +143,7 @@
 // CHECK1-NEXT:call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}__Z9gtid_testv_l48() #[[ATTR2:[0-9]+]]
 // CHECK1-NEXT:br label [[OMP_OFFLOAD_CONT]]
 // CHECK1:   omp_offload.cont:
-// CHECK1-NEXT:[[TMP15:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 0
-// CHECK1-NEXT:store i32 2, ptr [[TMP15]], align 4
-// CHECK1-NEXT:[[TMP16:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 1
-// CHECK1-NEXT:store i32 0, ptr [[TMP16]], align 4
-// CHECK1-NEXT:[[TMP17:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 2
-// CHECK1-NEXT:store ptr null, ptr [[TMP17]], align 8
-// CHECK1-NEXT:[[TMP18:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 3
-// CHECK1-NEXT:store ptr null, ptr [[TMP18]], align 8
-// CHECK1-NEXT:[[TMP19:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 4
-// CHECK1-NEXT:store ptr null, ptr [[TMP19]], align 8
-// CHECK1-NEXT:[[TMP20:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 5
-// CHECK1-NEXT:store ptr null, ptr [[TMP20]], align 8
-// CHECK1-NEXT:[[TMP21:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 6
-// CHECK1-NEXT:store ptr null, ptr [[TMP21]], align 8
-// CHECK1-NEXT:[[TMP22:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 7
-// CHECK1-NEXT:store ptr null, ptr [[TMP22]], align 8
-// CHECK1-NEXT:[[TMP23:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 8
-// CHECK1-NEXT:store i64 100, ptr [[TMP23]], align 8
-// CHECK1-NEXT:[[TMP24:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KERNEL_ARGS2]], i32 0, i32 9
-// CHECK1-NEXT:store i64 0, ptr [[TMP24]], align 8
-// CHECK1-NEXT:[[TMP25:%.*]] = getelementptr inbounds [[STRUCT___TGT_KERNEL_ARGUMENTS]], ptr [[KER

[PATCH] D156326: [OpenMP][Docs] Update 'loop' directive status in OpenMP support.

2023-07-26 Thread David Pagan via Phabricator via cfe-commits
ddpagan closed this revision.
ddpagan added a comment.

https://github.com/llvm/llvm-project/commit/b41bf9d8576f44e30726e42d31f760032c08333d


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156326/new/

https://reviews.llvm.org/D156326

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


[PATCH] D156326: [OpenMP][Docs] Update 'loop' directive status in OpenMP support.

2023-07-26 Thread David Pagan via Phabricator via cfe-commits
ddpagan created this revision.
ddpagan added reviewers: jdoerfert, jhuber6, jplehr.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
ddpagan requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Update status of #pragma omp loop (directive) and loop bind.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156326

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -120,9 +120,9 @@
 
+==+==+==+===+
 | loop | support != in the canonical loop form 
   | :good:`done` | D54441  
  |
 
+--+--+--+---+
-| loop | #pragma omp loop (directive)  
   | :part:`worked on`| 
  |
+| loop | #pragma omp loop (directive)  
   | :part:`partial`  | D145823 (combined forms)
  |
 
+--+--+--+---+
-| loop | #pragma omp loop bind 
   | :part:`worked on`| 
  |
+| loop | #pragma omp loop bind 
   | :part:`worked on`| D144634 (needs review)  
  |
 
+--+--+--+---+
 | loop | collapse imperfectly nested loop  
   | :good:`done` | 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -120,9 +120,9 @@
 +==+==+==+===+
 | loop | support != in the canonical loop form| :good:`done` | D54441|
 +--+--+--+---+
-| loop | #pragma omp loop (directive) | :part:`worked on`|   |
+| loop | #pragma omp loop (directive) | :part:`partial`  | D145823 (combined forms)  |
 +--+--+--+---+
-| loop | #pragma omp loop bind| :part:`worked on`|   |
+| loop | #pragma omp loop bind| :part:`worked on`| D144634 (needs review)|
 +--+--+--+---+
 | loop | collapse imperfectly nested loop | :good:`done` |   |
 +--

[PATCH] D145823: [OpenMP][CodeGen] Add codegen for combined 'loop' directives.

2023-07-05 Thread David Pagan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb61bde829bc: [OpenMP][CodeGen] Add codegen for combined 
'loop' directives. (authored by ddpagan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145823/new/

https://reviews.llvm.org/D145823

Files:
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/generic_loop_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_generic_loop_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_generic_loop_generic_mode_codegen.cpp
  clang/test/OpenMP/parallel_generic_loop_codegen.cpp
  clang/test/OpenMP/target_parallel_generic_loop_codegen-1.cpp
  clang/test/OpenMP/target_parallel_generic_loop_codegen-2.cpp
  clang/test/OpenMP/target_parallel_generic_loop_codegen-3.cpp
  clang/test/OpenMP/target_parallel_generic_loop_codegen.cpp
  clang/test/OpenMP/target_parallel_generic_loop_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_generic_loop_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_codegen-1.cpp
  clang/test/OpenMP/target_teams_generic_loop_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_depend_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_order_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_private_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_uses_allocators_codegen.cpp
  clang/test/OpenMP/teams_generic_loop_codegen-1.cpp
  clang/test/OpenMP/teams_generic_loop_codegen.cpp
  clang/test/OpenMP/teams_generic_loop_collapse_codgen.cpp
  clang/test/OpenMP/teams_generic_loop_private_codegen.cpp
  clang/test/OpenMP/teams_generic_loop_reduction_codegen.cpp

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


[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-06-22 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9823
+def err_omp_loop_reduction_clause : Error<
+  "reduction clause not handled with '#pragma omp loop bind(teams)'">;
 def warn_break_binds_to_switch : Warning<

Should be "allowed".



Comment at: clang/lib/Sema/SemaOpenMP.cpp:6127
+  bool UseClausesWithoutBind = false;
+
+  // Restricting to "#pragma omp loop bind"

This function only applies to OMPD_loop. If *Kind != OMPD_loop then should just 
return UseClauseWithoutBind.



Comment at: clang/test/OpenMP/generic_loop_ast_print.cpp:26
 //PRINT:   T j, z;
-//PRINT:   #pragma omp loop collapse(C) reduction(+: z) lastprivate(j) 
bind(thread)
+//PRINT:   #pragma omp simd collapse(C) reduction(+: z) lastprivate(j)
 //PRINT:   for (T i = 0; i < t; ++i)

The AST that is printed should be what was originally specified in the source.



Comment at: clang/test/OpenMP/loop_bind_codegen.cpp:1
+// expected-no-diagnostics
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ %s -emit-llvm -o - | 
FileCheck %s

Should auto-generate the the IR checking for this test using 
llvm/utils/update_cc_test_checks.py after verifying that what's generated is 
correct.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144634/new/

https://reviews.llvm.org/D144634

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


[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-03-01 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

How is bind(thread) not working? Runtime issue?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144634/new/

https://reviews.llvm.org/D144634

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


[PATCH] D118383: [OpenMP] Enable inoutset dependency-type in depend clause.

2022-01-27 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

> Is it a new mode from OpenMP 5.2? Or 5.1? Can you add a check for OpenMP 
> version, if so?

Thanks for catching this, Alexey. It is new in OpenMP 5.1. I'll add a check for 
this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118383/new/

https://reviews.llvm.org/D118383

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


[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-11-08 Thread David Pagan via Phabricator via cfe-commits
ddpagan updated this revision to Diff 385692.
ddpagan added a comment.

Fixed build problem (found during build of flang).  Added align clause to 
simple clause check.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112577/new/

https://reviews.llvm.org/D112577

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/align_clause_ast_print.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -363,6 +363,9 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_Align : Clause<"align"> {
+  let clangClass = "OMPAlignClause";
+}
 def OMPC_When: Clause<"when"> {}
 
 def OMPC_Bind : Clause<"bind"> {
@@ -1539,7 +1542,8 @@
 }
 def OMP_Allocate : Directive<"allocate"> {
   let allowedOnceClauses = [
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_DeclareVariant : Directive<"declare variant"> {
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1481,6 +1481,7 @@
 CHECK_SIMPLE_CLAUSE(AppendArgs, OMPC_append_args)
 CHECK_SIMPLE_CLAUSE(MemoryOrder, OMPC_memory_order)
 CHECK_SIMPLE_CLAUSE(Bind, OMPC_bind)
+CHECK_SIMPLE_CLAUSE(Align, OMPC_align)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2315,6 +2315,10 @@
   Visitor->AddStmt(C->getThreadID());
 }
 
+void OMPClauseEnqueue::VisitOMPAlignClause(const OMPAlignClause *C) {
+  Visitor->AddStmt(C->getAlignment());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/align_clause_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/align_clause_messages.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify
+
+int foobar() {
+  return 1;
+}
+
+int main(int argc, char *argv[]) {
+  // expected-note@+1 {{declared here}}
+  int a;
+  // expected-note@+1 {{declared here}}
+  int b;
+  // expected-note@+1 {{declared here}}
+  int c;
+  double f;
+  int foo2[10];
+
+// expected-error@+1 {{expected '(' after 'align'}}
+#pragma omp allocate(a) align
+// expected-error@+3 {{expected expression}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp allocate(a) align(
+// expected-error@+1 {{expected expression}}
+#pragma omp allocate(a) align()
+// expected-error@+4 {{expected ')'}}
+// expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'a' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(a
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'b' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(b)
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'c' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(c + 1)
+// expected-error@+1 {{expected an OpenMP directive}}
+#pragma omp align(2) allocate(a)
+// expected-error@+1 {{directive '#pragma omp allocate' cannot contain more than one 'align' clause}}
+#pragma omp allocate(a) align(2) align(4)
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(a) align(9)
+// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'double'}}
+#pragma omp allocate(a) align(f)
+}
+
+// Verify appropriate errors when using templates.
+template 
+T run() {
+  T foo[size];
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a po

[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-11-05 Thread David Pagan via Phabricator via cfe-commits
ddpagan updated this revision to Diff 385098.
ddpagan added a comment.

Successfully rebased, built, and tested.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112577/new/

https://reviews.llvm.org/D112577

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/align_clause_ast_print.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -363,6 +363,9 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_Align : Clause<"align"> {
+  let clangClass = "OMPAlignClause";
+}
 def OMPC_When: Clause<"when"> {}
 
 def OMPC_Bind : Clause<"bind"> {
@@ -1539,7 +1542,8 @@
 }
 def OMP_Allocate : Directive<"allocate"> {
   let allowedOnceClauses = [
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_DeclareVariant : Directive<"declare variant"> {
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2315,6 +2315,10 @@
   Visitor->AddStmt(C->getThreadID());
 }
 
+void OMPClauseEnqueue::VisitOMPAlignClause(const OMPAlignClause *C) {
+  Visitor->AddStmt(C->getAlignment());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/align_clause_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/align_clause_messages.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify
+
+int foobar() {
+  return 1;
+}
+
+int main(int argc, char *argv[]) {
+  // expected-note@+1 {{declared here}}
+  int a;
+  // expected-note@+1 {{declared here}}
+  int b;
+  // expected-note@+1 {{declared here}}
+  int c;
+  double f;
+  int foo2[10];
+
+// expected-error@+1 {{expected '(' after 'align'}}
+#pragma omp allocate(a) align
+// expected-error@+3 {{expected expression}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp allocate(a) align(
+// expected-error@+1 {{expected expression}}
+#pragma omp allocate(a) align()
+// expected-error@+4 {{expected ')'}}
+// expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'a' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(a
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'b' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(b)
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'c' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(c + 1)
+// expected-error@+1 {{expected an OpenMP directive}}
+#pragma omp align(2) allocate(a)
+// expected-error@+1 {{directive '#pragma omp allocate' cannot contain more than one 'align' clause}}
+#pragma omp allocate(a) align(2) align(4)
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(a) align(9)
+// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'double'}}
+#pragma omp allocate(a) align(f)
+}
+
+// Verify appropriate errors when using templates.
+template 
+T run() {
+  T foo[size];
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(foo) align(align)
+  return foo[0];
+}
+
+int template_test() {
+  double d;
+  // expected-note@+1 {{in instantiation of function template specialization 'run' requested here}}
+  d = run();
+  return 0;
+}
Index: clang/test/OpenMP/align_clause_ast_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/align_clause_ast_print.cpp
@@ -0,0 +1,134 @@
+// expected-no-diagnostics
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions   \
+//RU

[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-11-03 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

Thanks for reviewing the code, Aaron.




Comment at: clang/lib/Serialization/ASTWriter.cpp:5018
 Record.AddStmt(A->getAllocator());
+Record.AddStmt(A->getAlignment());
 Record.AddSourceRange(A->getRange());

aaron.ballman wrote:
> This can potentially add a null statement to emit to the serialized form.
The same thing can occur with A->getAllocator(). However, it's expected 
behavior. When these values are read in later, the allocator and alignment 
values are use to set the appropriate fields in the allocate directive. Null 
values are okay as they indicate whether or not a field has been specified (via 
an align or allocator clause).



Comment at: clang/lib/Serialization/ASTWriter.cpp:6224
+void OMPClauseWriter::VisitOMPAlignClause(OMPAlignClause *C) {
+  Record.AddStmt(C->getAlignment());
+  Record.AddSourceLocation(C->getLParenLoc());

aaron.ballman wrote:
> Same for this one, maybe?
This is called only when an align clause has been specified, so it's guaranteed 
to not be null.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112577/new/

https://reviews.llvm.org/D112577

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


[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-10-29 Thread David Pagan via Phabricator via cfe-commits
ddpagan added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:362-364
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+

aaron.ballman wrote:
> ABataev wrote:
> > Also worth to make it private
> I agree, I think these constructors should have their access reduced to at 
> least `protected`.
Agreed. I made them private, then created a function to build the clause rather 
than reference the constructor directly. This is similar to what we do for some 
other clauses. 



Comment at: clang/include/clang/AST/OpenMPClause.h:369
+  /// Returns alignment
+  Expr *getAlignment() const { return cast_or_null(Alignment); }
+

aaron.ballman wrote:
> I have a preference for improved const-correctness with this sort of thing, 
> where I'd rather see an overloaded pair of functions:
> ```
> const Expr *getAlignment() const { return cast_or_null(Alignment); }
> Expr *getAlignment() { return cast_or_null(Alignment); }
> ```
> 
> 
Agreed. Unfortunately, OpenMP code isn't set up well for this. A few clauses 
are, but not this one. So, trying to make this change led to an ugly rat's nest 
of other changes outside the scope of this fix. I'd like to see new clauses 
follow this pattern, though.



Comment at: clang/lib/AST/OpenMPClause.cpp:1615
+  OS << "align(";
+  Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
+  OS << ")";

aaron.ballman wrote:
> `getAlignment()` can return nullptr and it looks like the vast majority of 
> the calls to it are unprotected like this. Would it make sense to ensure that 
> `OMPAlignClause` can never have a nonnull alignment expression?
This particular code is only called when a legitimate align clause has been 
used, so we are guaranteed a non-nullptr. I looked over other references to 
getAlignment (most from other classes) and it didn't appear that any of them 
were unsafe.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112577/new/

https://reviews.llvm.org/D112577

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


[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-10-29 Thread David Pagan via Phabricator via cfe-commits
ddpagan updated this revision to Diff 383428.
ddpagan added a comment.

Thanks for the review, Aaron.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112577/new/

https://reviews.llvm.org/D112577

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/align_clause_ast_print.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -341,6 +341,9 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_Align : Clause<"align"> {
+  let clangClass = "OMPAlignClause";
+}
 def OMPC_When: Clause<"when"> {}
 
 //===--===//
@@ -1513,7 +1516,8 @@
 }
 def OMP_Allocate : Directive<"allocate"> {
   let allowedOnceClauses = [
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_DeclareVariant : Directive<"declare variant"> {
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2315,6 +2315,10 @@
   Visitor->AddStmt(C->getThreadID());
 }
 
+void OMPClauseEnqueue::VisitOMPAlignClause(const OMPAlignClause *C) {
+  Visitor->AddStmt(C->getAlignment());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/align_clause_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/align_clause_messages.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify
+
+int foobar() {
+  return 1;
+}
+
+int main(int argc, char *argv[]) {
+  // expected-note@+1 {{declared here}}
+  int a;
+  // expected-note@+1 {{declared here}}
+  int b;
+  // expected-note@+1 {{declared here}}
+  int c;
+  double f;
+  int foo2[10];
+
+// expected-error@+1 {{expected '(' after 'align'}}
+#pragma omp allocate(a) align
+// expected-error@+3 {{expected expression}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp allocate(a) align(
+// expected-error@+1 {{expected expression}}
+#pragma omp allocate(a) align()
+// expected-error@+4 {{expected ')'}}
+// expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'a' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(a
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'b' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(b)
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'c' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(c + 1)
+// expected-error@+1 {{expected an OpenMP directive}}
+#pragma omp align(2) allocate(a)
+// expected-error@+1 {{directive '#pragma omp allocate' cannot contain more than one 'align' clause}}
+#pragma omp allocate(a) align(2) align(4)
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(a) align(9)
+// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'double'}}
+#pragma omp allocate(a) align(f)
+}
+
+// Verify appropriate errors when using templates.
+template 
+T run() {
+  T foo[size];
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(foo) align(align)
+  return foo[0];
+}
+
+int template_test() {
+  double d;
+  // expected-note@+1 {{in instantiation of function template specialization 'run' requested here}}
+  d = run();
+  return 0;
+}
Index: clang/test/OpenMP/align_clause_ast_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/align_clause_ast_print.cpp
@@ -0,0 +1,134 @@
+// expected-no-diagnostics
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
+//RUN:   -x c++ -std=c++14 -fexceptions -fcxx

[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-10-27 Thread David Pagan via Phabricator via cfe-commits
ddpagan updated this revision to Diff 382701.
ddpagan added a comment.

Thanks for the review, Alexey.

Made the requested changes except for modifying "used_children". After looking 
over other clause classes, for example, OMPNumThreadsClause, we're being 
consistent in how we're declaring these. Let me know if I'm missing something 
there.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112577/new/

https://reviews.llvm.org/D112577

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/align_clause_ast_print.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -341,6 +341,9 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_Align : Clause<"align"> {
+  let clangClass = "OMPAlignClause";
+}
 def OMPC_When: Clause<"when"> {}
 
 //===--===//
@@ -1513,7 +1516,8 @@
 }
 def OMP_Allocate : Directive<"allocate"> {
   let allowedOnceClauses = [
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_DeclareVariant : Directive<"declare variant"> {
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2315,6 +2315,10 @@
   Visitor->AddStmt(C->getThreadID());
 }
 
+void OMPClauseEnqueue::VisitOMPAlignClause(const OMPAlignClause *C) {
+  Visitor->AddStmt(C->getAlignment());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/align_clause_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/align_clause_messages.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify
+
+int foobar() {
+  return 1;
+}
+
+int main(int argc, char *argv[]) {
+  // expected-note@+1 {{declared here}}
+  int a;
+  // expected-note@+1 {{declared here}}
+  int b;
+  // expected-note@+1 {{declared here}}
+  int c;
+  double f;
+  int foo2[10];
+
+// expected-error@+1 {{expected '(' after 'align'}}
+#pragma omp allocate(a) align
+// expected-error@+3 {{expected expression}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp allocate(a) align(
+// expected-error@+1 {{expected expression}}
+#pragma omp allocate(a) align()
+// expected-error@+4 {{expected ')'}}
+// expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'a' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(a
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'b' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(b)
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'c' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(c + 1)
+// expected-error@+1 {{expected an OpenMP directive}}
+#pragma omp align(2) allocate(a)
+// expected-error@+1 {{directive '#pragma omp allocate' cannot contain more than one 'align' clause}}
+#pragma omp allocate(a) align(2) align(4)
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(a) align(9)
+// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'double'}}
+#pragma omp allocate(a) align(f)
+}
+
+// Verify appropriate errors when using templates.
+template 
+T run() {
+  T foo[size];
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(foo) align(align)
+  return foo[0];
+}
+
+int template_test() {
+  double d;
+  // expected-note@+1 {{in instantiation of function template specialization 'run' requested here}}
+  d = run();
+  return 0;
+}
Index: clang/test/OpenMP/align_clause_ast_print.cpp
=

[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-10-26 Thread David Pagan via Phabricator via cfe-commits
ddpagan created this revision.
ddpagan added reviewers: ABataev, jdoerfert.
Herald added subscribers: arphaman, guansong, yaxunl.
Herald added a reviewer: aaron.ballman.
ddpagan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

[OPENMP51] Added basic parsing/sema/serialization support for 'align' clause 
for use with 'allocate' directive.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112577

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/align_clause_ast_print.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -341,6 +341,9 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_Align : Clause<"align"> {
+  let clangClass = "OMPAlignClause";
+}
 def OMPC_When: Clause<"when"> {}
 
 //===--===//
@@ -1513,7 +1516,8 @@
 }
 def OMP_Allocate : Directive<"allocate"> {
   let allowedOnceClauses = [
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_DeclareVariant : Directive<"declare variant"> {
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2315,6 +2315,10 @@
   Visitor->AddStmt(C->getThreadID());
 }
 
+void OMPClauseEnqueue::VisitOMPAlignClause(const OMPAlignClause *C) {
+  Visitor->AddStmt(C->getAlignment());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/align_clause_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/align_clause_messages.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify
+
+int foobar() {
+  return 1;
+}
+
+int main(int argc, char *argv[]) {
+  // expected-note@+1 {{declared here}}
+  int a;
+  // expected-note@+1 {{declared here}}
+  int b;
+  // expected-note@+1 {{declared here}}
+  int c;
+  double f;
+  int foo2[10];
+
+// expected-error@+1 {{expected '(' after 'align'}}
+#pragma omp allocate(a) align
+// expected-error@+3 {{expected expression}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp allocate(a) align(
+// expected-error@+1 {{expected expression}}
+#pragma omp allocate(a) align()
+// expected-error@+4 {{expected ')'}}
+// expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'a' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(a
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'b' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(b)
+// expected-error@+2 {{expression is not an integral constant expression}}
+// expected-note@+1 {{read of non-const variable 'c' is not allowed in a constant expression}}
+#pragma omp allocate(a) align(c + 1)
+// expected-error@+1 {{expected an OpenMP directive}}
+#pragma omp align(2) allocate(a)
+// expected-error@+1 {{directive '#pragma omp allocate' cannot contain more than one 'align' clause}}
+#pragma omp allocate(a) align(2) align(4)
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(a) align(9)
+// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'double'}}
+#pragma omp allocate(a) align(f)
+}
+
+// Verify appropriate errors when using templates.
+template 
+T run() {
+  T foo[size];
+// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+#pragma omp allocate(foo) align(align)
+  return foo[0];
+}
+
+int template_test() {
+  double d;
+  // expected-note@+1 {{in instantiation of function template specialization 'run' requested here}}
+  d = run();
+  return 0;
+}
Index: clang/test/OpenMP/align_clause_ast_print.cpp
===