[llvm] [Offload] Store kernel name in GenericKernelTy (PR #142799)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 05:41:35 PDT 2025


================
@@ -256,7 +256,12 @@ class DeviceImageTy {
 struct GenericKernelTy {
   /// Construct a kernel with a name and a execution mode.
   GenericKernelTy(const char *Name)
-      : Name(Name), PreferredNumThreads(0), MaxNumThreads(0) {}
+      : Name(Name), PreferredNumThreads(0), MaxNumThreads(0) {
+    // Ensure that the name is null terminated so getName() can just return the
+    // pointer
+    this->Name.push_back('\0');
+    this->Name.pop_back();
----------------
RossBrunton wrote:

I'm weary of some code in the future that does end up using the size or SmallString directly in the future.

Honestly though, with the amount of complications this is causing, I'm wondering if it's just better to use a std::string rather than a SmallString and not have to deal with it.

https://github.com/llvm/llvm-project/pull/142799


More information about the llvm-commits mailing list