[llvm] [SampleProfile] Fix bug where remapper returns empty string and crashing Sample Profile loader (PR #71479)
William Junda Huang via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 14:39:03 PST 2023
================
@@ -1788,8 +1788,11 @@ void SampleProfileReaderItaniumRemapper::applyRemapping(LLVMContext &Ctx) {
std::optional<StringRef>
SampleProfileReaderItaniumRemapper::lookUpNameInProfile(StringRef Fname) {
- if (auto Key = Remappings->lookup(Fname))
- return NameMap.lookup(Key);
+ if (auto Key = Remappings->lookup(Fname)) {
+ StringRef Result = NameMap.lookup(Key);
+ if (!Result.empty())
+ return Result;
----------------
huangjd wrote:
The comment in the header file should be clear enough that it returns a remapped name Only if a remapped symbol is found. The problem is the function's API design is bad (mixing both empty string and null to represent non-existent value). This should be addressed somewhere else.
https://github.com/llvm/llvm-project/pull/71479
More information about the llvm-commits
mailing list