[llvm] [llvm-profgen] Loading binary functions from .symtab when DWARF info is incomplete (PR #163654)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 22:08:42 PST 2025
================
@@ -1034,6 +1140,48 @@ void ProfiledBinary::computeInlinedContextSizeForFunc(
}
}
+void ProfiledBinary::loadSymbolsFromPseudoProbe() {
+ if (!UsePseudoProbes)
+ return;
+
+ const AddressProbesMap &Address2ProbesMap = getAddress2ProbesMap();
+ for (auto &[Addr, Range] : StartAddrToFuncRangeMap) {
+ auto Func = Range.Func;
+ if (!Range.IsFuncEntry || Func->NameStatus != DwarfNameStatus::Mismatch)
+ continue;
+#ifndef NDEBUG
+ if (PseudoProbeNames.count(Func))
+ continue;
+#endif
+ const auto &Probe = Address2ProbesMap.find(Addr).begin();
+ if (Probe != Address2ProbesMap.end()) {
+ const MCDecodedPseudoProbeInlineTree *InlineTreeNode =
+ Probe->get().getInlineTreeNode();
+ while (!InlineTreeNode->isTopLevelFunc())
+ InlineTreeNode = static_cast<MCDecodedPseudoProbeInlineTree *>(
+ InlineTreeNode->Parent);
+
+ auto TopLevelProbes = InlineTreeNode->getProbes();
+ auto TopProbe = TopLevelProbes.begin();
+ assert(TopProbe != TopLevelProbes.end() &&
+ TopProbe->getAddress() >= Addr &&
+ "Top level pseudo probe does not match function range");
+
+ const auto *ProbeDesc = getFuncDescForGUID(InlineTreeNode->Guid);
+ auto Ret = PseudoProbeNames.emplace(Func, ProbeDesc->FuncName);
+ assert((Ret.second || Ret.first->second == ProbeDesc->FuncName) &&
+ "Mismatched pseudo probe names");
+ }
+ }
+}
+
+StringRef ProfiledBinary::findPseudoProbeName(const BinaryFunction *Func) {
+ auto ProbeName = PseudoProbeNames.find(Func);
+ if (ProbeName == PseudoProbeNames.end())
+ return StringRef();
+ return ProbeName->second;
+}
----------------
HighW4y2H3ll wrote:
hmmm, the problem is `BinaryFunctions` is a map using its original DWARF name as the key.. If I'm going to replace the function name field of BinaryFunction, it probably be good to also update the key? but there're tons of pointer references pointing to the `BinaryFunction` in this map... It just feels safer (and.. maybe cleaner) to use a separate lookaside map and avoid patching the `BinaryFunction` at a later stage..?
https://github.com/llvm/llvm-project/pull/163654
More information about the llvm-commits
mailing list