[Openmp-commits] [PATCH] D130114: [OpenMP] Use Undef instead of null as pointer for inactive lanes

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jul 21 10:41:23 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7472b42b788e: [OpenMP] Use Undef instead of null as pointer for inactive lanes (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130114

Files:
  openmp/libomptarget/DeviceRTL/include/State.h
  openmp/libomptarget/DeviceRTL/include/Utils.h


Index: openmp/libomptarget/DeviceRTL/include/Utils.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Utils.h
+++ openmp/libomptarget/DeviceRTL/include/Utils.h
@@ -14,6 +14,8 @@
 
 #include "Types.h"
 
+#pragma omp begin declare target device_type(nohost)
+
 namespace _OMP {
 namespace utils {
 
@@ -72,10 +74,15 @@
   return V - V % Align;
 }
 
+/// A  pointer variable that has by design an `undef` value. Use with care.
+__attribute__((loader_uninitialized)) static void *const UndefPtr;
+
 #define OMP_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
 #define OMP_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
 
 } // namespace utils
 } // namespace _OMP
 
+#pragma omp end declare target
+
 #endif
Index: openmp/libomptarget/DeviceRTL/include/State.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/State.h
+++ openmp/libomptarget/DeviceRTL/include/State.h
@@ -277,7 +277,8 @@
 
 template <typename VTy, typename Ty> struct ValueRAII {
   ValueRAII(VTy &V, Ty NewValue, Ty OldValue, bool Active, IdentTy *Ident)
-      : Ptr(Active ? &V.lookup(/* IsReadonly */ false, Ident) : nullptr),
+      : Ptr(Active ? &V.lookup(/* IsReadonly */ false, Ident)
+                   : (Ty *)utils::UndefPtr),
         Val(OldValue), Active(Active) {
     if (!Active)
       return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130114.446573.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220721/aa55d73f/attachment.bin>


More information about the Openmp-commits mailing list