[llvm] [llvm-profgen] Loading binary functions from .symtab when DWARF info is incomplete (PR #163654)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 9 10:52:29 PST 2025
================
@@ -820,6 +830,65 @@ void ProfiledBinary::populateSymbolAddressList(const ObjectFile *Obj) {
}
}
+void ProfiledBinary::loadSymbolsFromSymtab(const ObjectFile *Obj) {
+ // Load binary functions from symbol table when Debug info is incomplete.
+ // Strip the internal suffixes which are not reflected in the DWARF info.
+ const SmallVector<StringRef, 10> Suffixes(
+ {// Internal suffixes from CoroSplit pass
+ ".cleanup", ".destroy", ".resume",
+ // Internal suffixes from Bolt
+ ".cold", ".warm",
+ // Compiler/LTO internal
+ ".llvm.", ".part.", ".isra.", ".constprop.", ".lto_priv."});
+ StringRef FileName = Obj->getFileName();
+ for (const SymbolRef &Symbol : Obj->symbols()) {
+ const SymbolRef::Type Type = unwrapOrError(Symbol.getType(), FileName);
+ const uint64_t StartAddr = unwrapOrError(Symbol.getAddress(), FileName);
+ const StringRef Name = unwrapOrError(Symbol.getName(), FileName);
+ uint64_t Size = 0;
+ if (isa<ELFObjectFileBase>(Symbol.getObject())) {
+ ELFSymbolRef ElfSymbol(Symbol);
+ Size = ElfSymbol.getSize();
+ }
+
+ if (Size == 0 || Type != SymbolRef::ST_Function)
+ continue;
+
+ const StringRef SymName =
+ FunctionSamples::getCanonicalFnName(Name, Suffixes);
+
+ auto Range = findFuncRange(StartAddr);
+ if (!Range || Range->StartAddress != StartAddr) {
----------------
WenleiHe wrote:
What is the cause for a range from symbol table to be found in dwarf, but with different start address?
Isn't that also an "inconsistent" case that we should warn about as part of the "else"?
So basically, if range for `StartAddr` is found, we expect the dwarf range and symbol table range to be identical, right?
Even if this is a funclet range (e.g. coroutine.resume), the range should still be identical from the one found in dwarf?
https://github.com/llvm/llvm-project/pull/163654
More information about the llvm-commits
mailing list