Skip to content

Commit 9958509

Browse files
[SYCL][sycl-post-link] Make GroupId a string to avoid dead references (#8499)
In certain cases the EntryPointGroup may outlive the string reference passed in its specified name, in which case its GroupId member dies prematurely. This can cause uses of the dead string reference. To avoid this, this commit makes the GroupId member into a copy of the passed string instead of a reference. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent e72ae4c commit 9958509

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/tools/sycl-post-link/ModuleSplitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ void ModuleDesc::dump() const {
675675
<< ", SpecConstMet:" << (Props.SpecConstsMet ? "YES" : "NO")
676676
<< ", LargeGRF:"
677677
<< (EntryPoints.Props.UsesLargeGRF ? "YES" : "NO") << "\n";
678-
dumpEntryPoints(entries(), EntryPoints.GroupId.str().c_str(), 1);
678+
dumpEntryPoints(entries(), EntryPoints.GroupId.c_str(), 1);
679679
llvm::errs() << "}\n";
680680
}
681681
#endif // NDEBUG

llvm/tools/sycl-post-link/ModuleSplitter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct EntryPointGroup {
7171
}
7272
};
7373

74-
StringRef GroupId;
74+
std::string GroupId;
7575
EntryPointSet Functions;
7676
Properties Props;
7777

@@ -125,7 +125,7 @@ class ModuleDesc {
125125
ModuleDesc(std::unique_ptr<Module> &&M, EntryPointGroup &&EntryPoints,
126126
const Properties &Props)
127127
: M(std::move(M)), EntryPoints(std::move(EntryPoints)), Props(Props) {
128-
Name = this->EntryPoints.GroupId.str();
128+
Name = this->EntryPoints.GroupId;
129129
}
130130

131131
ModuleDesc(std::unique_ptr<Module> &&M, const std::vector<std::string> &Names,

0 commit comments

Comments
 (0)