diff --git a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test --- a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test +++ b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test @@ -11,6 +11,7 @@ ; CHECK-SYM-LIST: Dump profile symbol list ; CHECK-SYM-LIST: bar ; CHECK-SYM-LIST: foo +; CHECK-SYM-LIST: main ; CHECK:[main:1 @ foo]:225:0 ; CHECK: 2.1: 14 diff --git a/llvm/test/tools/llvm-profgen/inline-noprobe2.test b/llvm/test/tools/llvm-profgen/inline-noprobe2.test --- a/llvm/test/tools/llvm-profgen/inline-noprobe2.test +++ b/llvm/test/tools/llvm-profgen/inline-noprobe2.test @@ -5,7 +5,7 @@ ; RUN: llvm-profgen --format=text --unsymbolized-profile=%t --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t1 --use-offset=0 ; RUN: FileCheck %s --input-file %t1 --check-prefix=CHECK -; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t +; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --populate-profile-symbol-list=1 ; RUN: llvm-profdata show -show-prof-sym-list -sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST ; CHECK-ARTIFICIAL-BRANCH: 3 @@ -21,6 +21,7 @@ ; CHECK-SYM-LIST: partition_pivot_first ; CHECK-SYM-LIST: partition_pivot_last ; CHECK-SYM-LIST: quick_sort +; CHECK-SYM-LIST: swap ;CHECK-RAW-PROFILE-NOT: 7f7448e889e4 diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp --- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp +++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp @@ -33,7 +33,7 @@ "meaningful for -extbinary)")); static cl::opt PopulateProfileSymbolList( - "populate-profile-symbol-list", cl::init(true), cl::Hidden, + "populate-profile-symbol-list", cl::init(false), cl::Hidden, cl::desc("Populate profile symbol list (only meaningful for -extbinary)")); static cl::opt RecursionCompression( @@ -97,16 +97,8 @@ // Populate profile symbol list if extended binary format is used. ProfileSymbolList SymbolList; - // Turn it off temporarily for CS profile. - if (FunctionSamples::ProfileIsCS && - !PopulateProfileSymbolList.getNumOccurrences()) - PopulateProfileSymbolList = false; - if (PopulateProfileSymbolList && OutputFormat == SPF_Ext_Binary) { - for (const auto &Item : ProfileMap) { - auto &Profile = Item.second; - SymbolList.add(Profile.getName(), true); - } + Binary->populateSymbolListFromDWARF(SymbolList); Writer->setProfileSymbolList(&SymbolList); } 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 @@ -382,6 +382,9 @@ return FuncSizeTracker.getFuncSizeForContext(Context); } + // Load the symbols from debug table and populate into symbol list. + void populateSymbolListFromDWARF(ProfileSymbolList &SymbolList); + const SampleContextFrameVector & getFrameLocationStack(uint64_t Offset, bool UseProbeDiscriminator = false) { auto I = Offset2LocStackMap.emplace(Offset, 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 @@ -10,6 +10,7 @@ #include "ErrorHandling.h" #include "ProfileGenerator.h" #include "llvm/ADT/Triple.h" +#include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/Demangle/Demangle.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/MC/TargetRegistry.h" @@ -599,6 +600,12 @@ assert(!StartOffset2FuncRangeMap.empty() && "Misssing debug info."); } +void ProfiledBinary::populateSymbolListFromDWARF( + ProfileSymbolList &SymbolList) { + for (auto &I : StartOffset2FuncRangeMap) + SymbolList.add(I.second.getFuncName()); +} + void ProfiledBinary::setupSymbolizer() { symbolize::LLVMSymbolizer::Options SymbolizerOpts; SymbolizerOpts.PrintFunctions =