[llvm] [PseudoProbe] Support loading pseudo probe from debug binary (PR #175698)
Haohai Wen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 14 22:30:26 PST 2026
================
@@ -445,12 +455,12 @@ void ProfiledBinary::checkPseudoProbe(const ObjectFile *Obj) {
}
}
- // set UsePseudoProbes flag, used for PerfReader
- UsePseudoProbes = HasProbeDescSection && HasPseudoProbeSection;
+ if (HasProbeDescSection && HasPseudoProbeSection)
+ PseudoProbeBinPath = ObjPath;
----------------
HaohaiWen wrote:
I think it is not Path/DebugBinaryPath. It is a copy of them managed by MemoryBuffer, which will be destructed after end of ProfiledBinary::load() scope since this OwningBinary is temporary variable.
The call stack is
```
1.
createBinary(Path); createBinary(DebugBinaryPath)
2.
Expected<OwningBinary<Binary>>
object::createBinary(StringRef Path, LLVMContext *Context, bool InitContent) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
3.
StringRef Binary::getFileName() const { return Data.getBufferIdentifier(); }
Data points to the MemoryBuffer in step2.
```
For MemoryBuffer, file name is managed by itself, not a reference to outside memory.
MemoryBufferMMapFile:
```
StringRef getBufferIdentifier() const override {
// The name is stored after the class itself.
return StringRef(reinterpret_cast<const char *>(this + 1) + sizeof(size_t),
*reinterpret_cast<const size_t *>(this + 1));
}
```
https://github.com/llvm/llvm-project/pull/175698
More information about the llvm-commits
mailing list