[llvm] [llvm-profgen][NFC] Fix dereference of empty function range when --disassemble-functions for symbols with no range (PR #219117)
Wei Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 22:35:54 PDT 2026
https://github.com/apolloww created https://github.com/llvm/llvm-project/pull/219117
When `--show-disassembly-only` is combined with `--disassemble-functions`, `decodePseudoProbe()` looks up each requested function's start address. If the start address has no entry in `StartAddrToFuncRangeMap`, `[]` operator returns an empty function range which causes crash when `getFuncName()` dereferences it. Look the range up instead of creating one, and fall back to the symbol's own GUID when there is none, so the requested function is still decoded.
Also fix a typo in `--disassemble-functions` help text. `SymbolStartAddrs` is keyed by the GUID of the raw symbol name, so mangled names are what actually resolve.
>From 97c1e8d0efdc6b658b3fc88661dcd56e8834fa0f Mon Sep 17 00:00:00 2001
From: Wei Wang <apollo.mobility at gmail.com>
Date: Wed, 26 Aug 2026 22:29:39 -0700
Subject: [PATCH] [llvm-profgen][NFC] Fix dereference of empty function range
when --disassemble-functions for symbols with no range
---
llvm/tools/llvm-profgen/ProfiledBinary.cpp | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 2d147d0af7353..9c70529f1e92a 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -72,7 +72,7 @@ static cl::opt<std::string>
static cl::list<std::string> DisassembleFunctions(
"disassemble-functions", cl::CommaSeparated,
- cl::desc("List of functions to print disassembly for. Accept demangled "
+ cl::desc("List of functions to print disassembly for. Accept mangled "
"names only. Only work with show-disassembly-only"),
cl::cat(ProfGenCategory));
@@ -167,9 +167,8 @@ void BinarySizeContextTracker::trackInlineesOptimizedAway(
for (auto &ProbeFrame : reverse(ProbeContext)) {
StringRef CallerName = ProbeFrame.first;
LineLocation CallsiteLoc(ProbeFrame.second, 0);
- SizeContext =
- SizeContext->getOrCreateChildContext(CallsiteLoc,
- FunctionId(CallerName));
+ SizeContext = SizeContext->getOrCreateChildContext(
+ CallsiteLoc, FunctionId(CallerName));
}
// Add 0 size to make known.
SizeContext->addFunctionSize(0);
@@ -501,9 +500,11 @@ void ProfiledBinary::decodePseudoProbe(const ObjectFile *Obj) {
auto GUID = Function::getGUIDAssumingExternalLinkage(F.first());
if (auto StartAddr = SymbolStartAddrs.lookup(GUID)) {
FuncStartAddresses[GUID] = StartAddr;
- FuncRange &Range = StartAddrToFuncRangeMap[StartAddr];
- GuidFilter.insert(
- Function::getGUIDAssumingExternalLinkage(Range.getFuncName()));
+ if (FuncRange *Range = findFuncRangeForStartAddr(StartAddr))
+ GuidFilter.insert(
+ Function::getGUIDAssumingExternalLinkage(Range->getFuncName()));
+ else
+ GuidFilter.insert(GUID);
}
}
}
More information about the llvm-commits
mailing list