diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h --- a/llvm/tools/llvm-profgen/ProfiledBinary.h +++ b/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 & diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp --- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp +++ b/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(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(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(SymbolizerOpts); + return SymbolizerOpts; } SampleContextFrameVector ProfiledBinary::symbolize(const InstructionPointer &IP,