[PATCH] D151441: Avoid pointless canonicalize when using Dwarf names
Mark Santaniello via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 06:48:14 PDT 2023
marksantaniello created this revision.
Herald added subscribers: hoy, wlei.
Herald added a project: All.
marksantaniello requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
CPU profile indicated memcmp was hot due to the two rfind calls in
getCanonicalFnName. If UseSymbolTable is false, we can avoid the cost entirely.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151441
Files:
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h
Index: llvm/tools/llvm-profgen/ProfiledBinary.h
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.h
+++ llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -190,10 +190,12 @@
std::string Path;
// Path of the debug info binary.
std::string DebugBinaryPath;
- // Path of symbolizer path which should be pointed to binary with debug info.
- StringRef SymbolizerPath;
// The target triple.
Triple TheTriple;
+ // Path of symbolizer path which should be pointed to binary with debug info.
+ StringRef SymbolizerPath;
+ // Options used to configure the symbolizer
+ symbolize::LLVMSymbolizer::Options SymbolizerOpts;
// The runtime base address that the first executable segment is loaded at.
uint64_t BaseAddress = 0;
// The runtime base address that the first loadabe segment is loaded at.
@@ -304,7 +306,7 @@
// Set up disassembler and related components.
void setUpDisassembler(const ELFObjectFileBase *Obj);
- void setupSymbolizer();
+ symbolize::LLVMSymbolizer::Options getSymbolizerOpts() const;
// Load debug info of subprograms from DWARF section.
void loadSymbolsFromDWARF(ObjectFile &Obj);
@@ -495,7 +497,7 @@
SampleContextFrameVector
getFrameLocationStack(uint64_t Address, bool UseProbeDiscriminator = false) {
InstructionPointer IP(this, Address);
- return symbolize(IP, true, UseProbeDiscriminator);
+ return symbolize(IP, SymbolizerOpts.UseSymbolTable, UseProbeDiscriminator);
}
const SampleContextFrameVector &
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -163,12 +163,13 @@
}
ProfiledBinary::ProfiledBinary(const StringRef ExeBinPath,
- const StringRef DebugBinPath)
- : Path(ExeBinPath), DebugBinaryPath(DebugBinPath), ProEpilogTracker(this),
+ const StringRef DebugBinPath)
+ : Path(ExeBinPath), DebugBinaryPath(DebugBinPath),
+ SymbolizerOpts(getSymbolizerOpts()), ProEpilogTracker(this),
+ Symbolizer(std::make_unique<symbolize::LLVMSymbolizer>(SymbolizerOpts)),
TrackFuncContextSize(EnableCSPreInliner && UseContextCostForPreInliner) {
// Point to executable binary if debug info binary is not specified.
SymbolizerPath = DebugBinPath.empty() ? ExeBinPath : DebugBinPath;
- setupSymbolizer();
if (InferMissingFrames)
MissingContextInferrer = std::make_unique<MissingFrameInferrer>(this);
load();
@@ -840,7 +841,7 @@
SymbolList.add(I.second.getFuncName());
}
-void ProfiledBinary::setupSymbolizer() {
+symbolize::LLVMSymbolizer::Options ProfiledBinary::getSymbolizerOpts() const {
symbolize::LLVMSymbolizer::Options SymbolizerOpts;
SymbolizerOpts.PrintFunctions =
DILineInfoSpecifier::FunctionNameKind::LinkageName;
@@ -849,7 +850,7 @@
SymbolizerOpts.UseSymbolTable = false;
SymbolizerOpts.RelativeAddresses = false;
SymbolizerOpts.DWPName = DWPPath;
- Symbolizer = std::make_unique<symbolize::LLVMSymbolizer>(SymbolizerOpts);
+ return SymbolizerOpts;
}
SampleContextFrameVector ProfiledBinary::symbolize(const InstructionPointer &IP,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151441.525583.patch
Type: text/x-patch
Size: 3286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230525/7fe2fd72/attachment.bin>
More information about the llvm-commits
mailing list