From 4f02965ae2462b2ba05426e88ac22845e12295aa Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Wed, 2 Jul 2025 14:11:05 +0100 Subject: [PATCH] [Offload] Store kernel name in GenericKernelTy (#142799) GenericKernelTy has a pointer to the name that was used to create it. However, the name passed in as an argument may not outlive the kernel. Instead, GenericKernelTy now contains a std::string, and copies the name into there. --- offload/plugins-nextgen/common/include/PluginInterface.h | 4 ++-- offload/plugins-nextgen/common/src/PluginInterface.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/offload/plugins-nextgen/common/include/PluginInterface.h b/offload/plugins-nextgen/common/include/PluginInterface.h index fbc798faec24..b5addc13d664 100644 --- a/offload/plugins-nextgen/common/include/PluginInterface.h +++ b/offload/plugins-nextgen/common/include/PluginInterface.h @@ -317,7 +317,7 @@ struct GenericKernelTy { AsyncInfoWrapperTy &AsyncInfoWrapper) const = 0; /// Get the kernel name. - const char *getName() const { return Name; } + const char *getName() const { return Name.c_str(); } /// Get the kernel image. DeviceImageTy &getImage() const { @@ -413,7 +413,7 @@ private: } /// The kernel name. - const char *Name; + std::string Name; /// The image that contains this kernel. DeviceImageTy *ImagePtr = nullptr; diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp index ac7031b6e881..81b9d423e13d 100644 --- a/offload/plugins-nextgen/common/src/PluginInterface.cpp +++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp @@ -456,7 +456,7 @@ Error GenericKernelTy::init(GenericDeviceTy &GenericDevice, KernelEnvironment = KernelEnvironmentTy{}; DP("Failed to read kernel environment for '%s' Using default Bare (0) " "execution mode\n", - Name); + getName()); } // Max = Config.Max > 0 ? min(Config.Max, Device.Max) : Device.Max;