[PATCH] D95765: [OpenMP] Introduce the `disable_selector_propagation` variant selector trait

2021-03-11 Thread Johannes Doerfert 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 rGb2642456abc6: [OpenMP] Introduce the 
`disable_selector_propagation` variant selector trait (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D95765?vs=320361&id=330142#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95765

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/begin_declare_variant_nested_propagation.c
  clang/test/OpenMP/declare_variant_messages.c
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1057,6 +1057,7 @@
 __OMP_TRAIT_PROPERTY(implementation, extension, match_none)
 __OMP_TRAIT_PROPERTY(implementation, extension, disable_implicit_base)
 __OMP_TRAIT_PROPERTY(implementation, extension, allow_templates)
+__OMP_TRAIT_PROPERTY(implementation, extension, disable_selector_propagation)
 
 __OMP_TRAIT_SET(user)
 
Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -170,6 +170,14 @@
 int conflicting_nested_score(void);
 #pragma omp end declare variant
 
+#pragma omp begin declare variant match(implementation = {vendor(score(1) \
+ : llvm),extension(disable_selector_propagation)})
+#pragma omp declare variant(foo) match(implementation = {vendor(score(2) \
+: llvm)})
+int conflicting_nested_score_no_prop(void);
+#pragma omp end declare variant
+
+
 // FIXME: We should build the conjuction of different conditions, see also the score fixme above.
 #pragma omp begin declare variant match(user = {condition(1)})
 #pragma omp declare variant(foo) match(user = {condition(1)}) // expected-error {{nested user conditions in OpenMP context selector not supported (yet)}}
Index: clang/test/OpenMP/begin_declare_variant_nested_propagation.c
===
--- clang/test/OpenMP/begin_declare_variant_nested_propagation.c
+++ clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
-// expected-no-diagnostics
 
 #pragma omp begin declare variant match(user={condition(1)}, device={kind(cpu)}, implementation={extension(match_any)})
 #pragma omp begin declare variant match(device = {kind(cpu, fpga)})
@@ -12,3 +11,18 @@
  this is never reached
 #pragma omp end declare variant
 #pragma omp end declare variant
+
+#pragma omp begin declare variant match(implementation={extension(disable_implicit_base, disable_selector_propagation)})
+
+ void without_implicit_base() {}
+
+#pragma omp begin declare variant match(implementation = {vendor(llvm)})
+ void with_implicit_base() {}
+#pragma omp end declare variant
+
+#pragma omp end declare variant
+
+ void test() {
+   without_implicit_base(); // expected-warning{{implicit declaration of function 'without_implicit_base' is invalid in C99}}
+   with_implicit_base();
+ }
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -948,6 +948,10 @@
   TraitProperty::implementation_extension_disable_implicit_base)
 return true;
 
+  if (TIProperty.Kind ==
+  TraitProperty::implementation_extension_disable_selector_propagation)
+return true;
+
   if (TIProperty.Kind ==
   TraitProperty::implementation_extension_allow_templates)
 return true;
@@ -1460,7 +1464,11 @@
 return false;
 
   // Merge the parent/outer trait info into the one we just parsed and diagnose
-  // problems.
+  // problems. Can be disabled by the disable_selector_propagation extension.
+  if (ParentTI->isExtensionActive(
+  llvm::omp::TraitProperty::
+  implementation_extension_disable_selector_propagation))
+return false;
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4007,8 +4007,9 @@
 match_all
 match_any
 match_none
-disable_implicit_base
 allow_templates
+disable_implicit_base
+   

[PATCH] D95765: [OpenMP] Introduce the `disable_selector_propagation` variant selector trait

2021-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95765

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


[PATCH] D95765: [OpenMP] Introduce the `disable_selector_propagation` variant selector trait

2021-02-01 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Yes, OK. I'm a little nervous that variant is evolving into a turing complete 
sublanguage, but I see the use of opting out of the implicit inheritance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95765

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


[PATCH] D95765: [OpenMP] Introduce the `disable_selector_propagation` variant selector trait

2021-01-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: bollu.
Herald added a reviewer: aaron.ballman.
jdoerfert requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

Nested `omp [begin|end] declare variant` inherit the selectors from
surrounding `omp (begin|end) declare variant` constructs. To stop such
propagation the user can add the `disable_selector_propagation` to the
`extension` set in the `implementation` selector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95765

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/begin_declare_variant_nested_propagation.c
  clang/test/OpenMP/declare_variant_messages.c
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1057,6 +1057,7 @@
 __OMP_TRAIT_PROPERTY(implementation, extension, match_none)
 __OMP_TRAIT_PROPERTY(implementation, extension, disable_implicit_base)
 __OMP_TRAIT_PROPERTY(implementation, extension, allow_templates)
+__OMP_TRAIT_PROPERTY(implementation, extension, disable_selector_propagation)
 
 __OMP_TRAIT_SET(user)
 
Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -170,6 +170,14 @@
 int conflicting_nested_score(void);
 #pragma omp end declare variant
 
+#pragma omp begin declare variant match(implementation = {vendor(score(1) \
+ : llvm),extension(disable_selector_propagation)})
+#pragma omp declare variant(foo) match(implementation = {vendor(score(2) \
+: llvm)})
+int conflicting_nested_score_no_prop(void);
+#pragma omp end declare variant
+
+
 // FIXME: We should build the conjuction of different conditions, see also the score fixme above.
 #pragma omp begin declare variant match(user = {condition(1)})
 #pragma omp declare variant(foo) match(user = {condition(1)}) // expected-error {{nested user conditions in OpenMP context selector not supported (yet)}}
Index: clang/test/OpenMP/begin_declare_variant_nested_propagation.c
===
--- clang/test/OpenMP/begin_declare_variant_nested_propagation.c
+++ clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -1,8 +1,22 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
-// expected-no-diagnostics
 
 #pragma omp begin declare variant match(implementation={extension(match_any)})
 #pragma omp begin declare variant match(device = {vendor(cray, ibm)})
  this is never reached, we cannot have a cray ibm compiler hybrid, I hope.
 #pragma omp end declare variant
 #pragma omp end declare variant
+
+#pragma omp begin declare variant match(implementation={extension(disable_implicit_base, disable_selector_propagation)})
+
+ void without_implicit_base() {}
+
+#pragma omp begin declare variant match(implementation = {vendor(llvm)})
+ void with_implicit_base() {}
+#pragma omp end declare variant
+
+#pragma omp end declare variant
+
+ void test() {
+   without_implicit_base(); // expected-warning{{implicit declaration of function 'without_implicit_base' is invalid in C99}}
+   with_implicit_base();
+ }
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -947,6 +947,10 @@
   TraitProperty::implementation_extension_disable_implicit_base)
 return true;
 
+  if (TIProperty.Kind ==
+  TraitProperty::implementation_extension_disable_selector_propagation)
+return true;
+
   if (TIProperty.Kind ==
   TraitProperty::implementation_extension_allow_templates)
 return true;
@@ -1459,7 +1463,11 @@
 return false;
 
   // Merge the parent/outer trait info into the one we just parsed and diagnose
-  // problems.
+  // problems. Can be disabled by the disable_selector_propagation extension.
+  if (ParentTI->isExtensionActive(
+  llvm::omp::TraitProperty::
+  implementation_extension_disable_selector_propagation))
+return false;
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDoc