================
@@ -453,6 +453,21 @@ void CIRGenFunction::emitStoreThroughLValue(RValue src, 
LValue dst,
   emitStoreOfScalar(src.getValue(), dst, isInit);
 }
 
+static Address emitDeclTargetVarDeclLValue(CIRGenFunction &cgf, const Expr *e,
+                                           const VarDecl *vd) {
+  std::optional<OMPDeclareTargetDeclAttr::MapTypeTy> res =
+      OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(vd);
+  // MT_Local, and MT_To/MT_Enter without unified memory, use direct access.
+  if (!res || *res == OMPDeclareTargetDeclAttr::MT_Local ||
+      ((*res == OMPDeclareTargetDeclAttr::MT_To ||
+        *res == OMPDeclareTargetDeclAttr::MT_Enter) &&
+       !cgf.cgm.getOpenMPRuntime().hasRequiresUnifiedSharedMemory()))
+    return Address::invalid();
----------------
steffenlarsen wrote:

Nit; This becomes hard to read. Maybe we could split it up?

```suggestion
  std::optional<OMPDeclareTargetDeclAttr::MapTypeTy> res =
      OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(vd);
  if (!res)
    return Address::invalid();
  // MT_Local use direct access.
  if (*res == OMPDeclareTargetDeclAttr::MT_Local)
    return Address::invalid();
  // MT_To/MT_Enter without unified memory, use direct access.
  if ((*res == OMPDeclareTargetDeclAttr::MT_To ||
        *res == OMPDeclareTargetDeclAttr::MT_Enter) &&
       !cgf.cgm.getOpenMPRuntime().hasRequiresUnifiedSharedMemory())
    return Address::invalid();
```

It makes for more code and it is really a preference. Feel free to keep what 
you have.

https://github.com/llvm/llvm-project/pull/234075
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to