[Openmp-commits] [openmp] 913622d - [Libomptarget] Remove remaining global constructors in plugins (#75814)

via Openmp-commits openmp-commits at lists.llvm.org
Mon Dec 18 09:01:07 PST 2023


Author: Joseph Huber
Date: 2023-12-18T11:01:02-06:00
New Revision: 913622d012f72edb5ac3a501cef8639d0ebe471b

URL: https://github.com/llvm/llvm-project/commit/913622d012f72edb5ac3a501cef8639d0ebe471b
DIFF: https://github.com/llvm/llvm-project/commit/913622d012f72edb5ac3a501cef8639d0ebe471b.diff

LOG: [Libomptarget] Remove remaining global constructors in plugins (#75814)

Summary:
This patch fixes the remaining global constructor in the plguins after
addressing the ones in the JIT interface. This struct was mistakenly
using global constructors as not all the members were being initialized
properly. This was almost certainly being optimized out because it's
trivial, but would still be present in debug builds and prevented us
from compiling with `-Werror=global-constructors`. We will want to do
that once offloading is moved to a runtimes only build.

Added: 
    

Modified: 
    openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
index 3c7d1ca8998787..1d96468340a083 100644
--- a/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
@@ -49,15 +49,15 @@ struct RecordReplayTy {
 
 private:
   // Memory pointers for recording, replaying memory.
-  void *MemoryStart;
-  void *MemoryPtr;
-  size_t MemorySize;
-  size_t TotalSize;
-  GenericDeviceTy *Device;
+  void *MemoryStart = nullptr;
+  void *MemoryPtr = nullptr;
+  size_t MemorySize = 0;
+  size_t TotalSize = 0;
+  GenericDeviceTy *Device = nullptr;
   std::mutex AllocationLock;
 
-  RRStatusTy Status;
-  bool ReplaySaveOutput;
+  RRStatusTy Status = RRDeactivated;
+  bool ReplaySaveOutput = false;
   bool UsedVAMap = false;
   uintptr_t MemoryOffset = 0;
 
@@ -190,9 +190,6 @@ struct RecordReplayTy {
   void setStatus(RRStatusTy Status) { this->Status = Status; }
   bool isSaveOutputEnabled() const { return ReplaySaveOutput; }
 
-  RecordReplayTy()
-      : Status(RRStatusTy::RRDeactivated), ReplaySaveOutput(false) {}
-
   void saveImage(const char *Name, const DeviceImageTy &Image) {
     SmallString<128> ImageName = {Name, ".image"};
     std::error_code EC;
@@ -352,8 +349,9 @@ struct RecordReplayTy {
       Device->free(MemoryStart);
     }
   }
+};
 
-} RecordReplay;
+static RecordReplayTy RecordReplay;
 
 // Extract the mapping of host function pointers to device function pointers
 // from the entry table. Functions marked as 'indirect' in OpenMP will have


        


More information about the Openmp-commits mailing list