LLVM profile (text format) has corrupt names for called functions
- Dominant language
- C++
- Stars
- 619
- Forks
- 127
- PR merge metrics
- No merged PRs in 30d
Description
Called function names in LLVM profiles are sometimes corrupt - see the sixth line here:
```
hot:8187856:16040
3: 12976
4: 12976
5: 12976
6: 12976
3: P▒}:2335680
2: 12976
3: 12976
```
This looks to be a string reference counting problem. This fixes it:
```
diff --git a/llvm_profile_writer.cc b/llvm_profile_writer.cc
index 3da7a1f..04b3f7c 100644
--- a/llvm_profile_writer.cc
+++ b/llvm_profile_writer.cc
@@ -94,10 +94,10 @@ void LLVMProfileBuilder::VisitCallsite(const Callsite &callsite) {
inline_stack_.pop_back();
}
auto &caller_profile = *(inline_stack_.back());
- auto CalleeName = GetNameRef(Symbol::Name(callsite.second)).str();
+ auto CalleeName = GetNameRef(Symbol::Name(callsite.second));
auto &callee_profile =
caller_profile.functionSamplesAt(llvm::sampleprof::LineLocation(
- line, discriminator))[CalleeName];
+ line, discriminator))[CalleeName.str()];
callee_profile.setName(CalleeName);
inline_stack_.push_back(&callee_profile);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.