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

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 05:48:11 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();
----------------
jhuber6 wrote:

Honestly, I don't know if this is necessary. If the pointer isn't null terminated then this will just explode before we even get here, right? Surely the constructor to `SmallString` is calling `strlen` somewhere.

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


More information about the llvm-commits mailing list