Skip to content

Commit 913622d

Browse files
authored
[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.
1 parent fade675 commit 913622d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ struct RecordReplayTy {
4949

5050
private:
5151
// Memory pointers for recording, replaying memory.
52-
void *MemoryStart;
53-
void *MemoryPtr;
54-
size_t MemorySize;
55-
size_t TotalSize;
56-
GenericDeviceTy *Device;
52+
void *MemoryStart = nullptr;
53+
void *MemoryPtr = nullptr;
54+
size_t MemorySize = 0;
55+
size_t TotalSize = 0;
56+
GenericDeviceTy *Device = nullptr;
5757
std::mutex AllocationLock;
5858

59-
RRStatusTy Status;
60-
bool ReplaySaveOutput;
59+
RRStatusTy Status = RRDeactivated;
60+
bool ReplaySaveOutput = false;
6161
bool UsedVAMap = false;
6262
uintptr_t MemoryOffset = 0;
6363

@@ -190,9 +190,6 @@ struct RecordReplayTy {
190190
void setStatus(RRStatusTy Status) { this->Status = Status; }
191191
bool isSaveOutputEnabled() const { return ReplaySaveOutput; }
192192

193-
RecordReplayTy()
194-
: Status(RRStatusTy::RRDeactivated), ReplaySaveOutput(false) {}
195-
196193
void saveImage(const char *Name, const DeviceImageTy &Image) {
197194
SmallString<128> ImageName = {Name, ".image"};
198195
std::error_code EC;
@@ -352,8 +349,9 @@ struct RecordReplayTy {
352349
Device->free(MemoryStart);
353350
}
354351
}
352+
};
355353

356-
} RecordReplay;
354+
static RecordReplayTy RecordReplay;
357355

358356
// Extract the mapping of host function pointers to device function pointers
359357
// from the entry table. Functions marked as 'indirect' in OpenMP will have

0 commit comments

Comments
 (0)