[clang] [OpenACC] Implement Duffs-Device restriction for Compute Constructs (PR #83460)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 10:37:04 PST 2024


================
@@ -534,6 +534,25 @@ class Scope {
     return false;
   }
 
+  /// Determine if this scope (or its parents) are a compute construct inside of
+  /// the nearest 'switch' scope.  This is needed to check whether we are inside
+  /// of a 'duffs' device, which is an illegal branch into a compute construct.
+  bool isInOpenACCComputeConstructBeforeSwitch() const {
+    for (const Scope *S = this; S; S = S->getParent()) {
+      if (S->getFlags() & Scope::OpenACCComputeConstructScope)
+        return true;
+      if (S->getFlags() & Scope::SwitchScope)
+        return false;
+
+      if (S->getFlags() &
+          (Scope::FnScope | Scope::ClassScope | Scope::BlockScope |
+           Scope::TemplateParamScope | Scope::FunctionPrototypeScope |
+           Scope::AtCatchScope | Scope::ObjCMethodScope))
+        return false;
----------------
erichkeane wrote:

I wasn't really sure how to be honest.  it has slightly different logic, so without some flag to choose between the two behaviors, I couldn't come up with a way?  And I wasn't sure that was better.

WDYT""

https://github.com/llvm/llvm-project/pull/83460


More information about the cfe-commits mailing list