[llvm] [Offload] Store kernel name in GenericKernelTy (PR #142799)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 08:45:53 PDT 2025
================
@@ -296,7 +296,13 @@ 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, &Name[strlen(Name) + 1]), PreferredNumThreads(0),
+ MaxNumThreads(0) {
+ // The null terminator from the input string was also copied to ensure that
+ // Name.data() will always be null terminated. Pop the last character to
+ // ensure that Name.size is accurate.
+ this->Name.pop_back();
+ }
----------------
jhuber6 wrote:
```suggestion
: Name(StringRef(Name, strlen(Name) + 1)), PreferredNumThreads(0),
MaxNumThreads(0) {}
```
Does this not work? The `getName` should return the correct const-char pointer.
https://github.com/llvm/llvm-project/pull/142799
More information about the llvm-commits
mailing list