[llvm] 27c3732 - Avoid pointless canonicalize when using Dwarf names
Wenlei He via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 08:14:55 PDT 2023
Author: Mark Santaniello
Date: 2023-05-25T08:14:11-07:00
New Revision: 27c37327da67020f938aabf0f6405f57d688441e
URL: https://github.com/llvm/llvm-project/commit/27c37327da67020f938aabf0f6405f57d688441e
DIFF: https://github.com/llvm/llvm-project/commit/27c37327da67020f938aabf0f6405f57d688441e.diff
LOG: Avoid pointless canonicalize when using Dwarf names
CPU profile indicated memcmp was hot due to the two rfind calls in
getCanonicalFnName. If UseSymbolTable is false, we can avoid the cost entirely.
For CSSPGO profiles I've measured ~5% speedup with this change.
Profile similarity before/after matches 100%.
Reviewed By: wenlei
Differential Revision: https://reviews.llvm.org/D151441
Added:
Modified:
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 781c61d0da88d..ebd455709472d 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -163,12 +163,13 @@ void BinarySizeContextTracker::trackInlineesOptimizedAway(
}
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 @@ void ProfiledBinary::populateSymbolListFromDWARF(
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 @@ void ProfiledBinary::setupSymbolizer() {
SymbolizerOpts.UseSymbolTable = false;
SymbolizerOpts.RelativeAddresses = false;
SymbolizerOpts.DWPName = DWPPath;
- Symbolizer = std::make_unique<symbolize::LLVMSymbolizer>(SymbolizerOpts);
+ return SymbolizerOpts;
}
SampleContextFrameVector ProfiledBinary::symbolize(const InstructionPointer &IP,
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h
index c410b98200de0..a6d78c661cc1c 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.h
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -190,10 +190,12 @@ class ProfiledBinary {
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 @@ class ProfiledBinary {
// 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 @@ class ProfiledBinary {
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 &
More information about the llvm-commits
mailing list