diff options
author | Rong Xu <xur@google.com> | 2017-03-15 21:47:27 +0000 |
---|---|---|
committer | Rong Xu <xur@google.com> | 2017-03-15 21:47:27 +0000 |
commit | 670b4228b07bf061c814dd0f078fef528755b5ad (patch) | |
tree | a76aa9cfa1f2080fa5f7dcbb5fbcda2fa3ef43c1 /tools/llvm-profdata | |
parent | e822046c8012751e0e144fa0905a81048d22c839 (diff) |
[PGO] Value profile for size of memory intrinsic calls
This patch adds the value profile support to profile the size parameter of
memory intrinsic calls: memcpy, memcmp, and memmov.
Differential Revision: http://reviews.llvm.org/D28965
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-profdata')
-rw-r--r-- | tools/llvm-profdata/llvm-profdata.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp index 6164d470955..a257910ecf7 100644 --- a/tools/llvm-profdata/llvm-profdata.cpp +++ b/tools/llvm-profdata/llvm-profdata.cpp @@ -458,7 +458,7 @@ typedef struct ValueSitesStats { static void traverseAllValueSites(const InstrProfRecord &Func, uint32_t VK, ValueSitesStats &Stats, raw_fd_ostream &OS, - InstrProfSymtab &Symtab) { + InstrProfSymtab *Symtab) { uint32_t NS = Func.getNumValueSites(VK); Stats.TotalNumValueSites += NS; for (size_t I = 0; I < NS; ++I) { @@ -473,8 +473,11 @@ static void traverseAllValueSites(const InstrProfRecord &Func, uint32_t VK, } for (uint32_t V = 0; V < NV; V++) { OS << "\t[ " << I << ", "; - OS << Symtab.getFuncName(VD[V].Value) << ", " << VD[V].Count; - OS << " ]\n"; + if (Symtab == nullptr) + OS << VD[V].Value; + else + OS << Symtab->getFuncName(VD[V].Value); + OS << ", " << VD[V].Count << " ]\n"; } } } @@ -494,7 +497,7 @@ static void showValueSitesStats(raw_fd_ostream &OS, uint32_t VK, } static int showInstrProfile(const std::string &Filename, bool ShowCounts, - bool ShowIndirectCallTargets, + bool ShowIndirectCallTargets, bool ShowMemOPSizes, bool ShowDetailedSummary, std::vector<uint32_t> DetailedSummaryCutoffs, bool ShowAllFunctions, @@ -547,6 +550,11 @@ static int showInstrProfile(const std::string &Filename, bool ShowCounts, OS << " Indirect Call Site Count: " << Func.getNumValueSites(IPVK_IndirectCallTarget) << "\n"; + uint32_t NumMemOPCalls = Func.getNumValueSites(IPVK_MemOPSize); + if (ShowMemOPSizes && NumMemOPCalls > 0) + OS << " Number of Memory Intrinsics Calls: " << NumMemOPCalls + << "\n"; + if (ShowCounts) { OS << " Block counts: ["; size_t Start = (IsIRInstr ? 0 : 1); @@ -560,7 +568,13 @@ static int showInstrProfile(const std::string &Filename, bool ShowCounts, OS << " Indirect Target Results:\n"; traverseAllValueSites(Func, IPVK_IndirectCallTarget, VPStats[IPVK_IndirectCallTarget], OS, - Reader->getSymtab()); + &(Reader->getSymtab())); + } + + if (ShowMemOPSizes && NumMemOPCalls > 0) { + OS << " Memory Instrinsic Size Results:\n"; + traverseAllValueSites(Func, IPVK_MemOPSize, VPStats[IPVK_MemOPSize], OS, + nullptr); } } } @@ -575,12 +589,18 @@ static int showInstrProfile(const std::string &Filename, bool ShowCounts, OS << "Total functions: " << PS->getNumFunctions() << "\n"; OS << "Maximum function count: " << PS->getMaxFunctionCount() << "\n"; OS << "Maximum internal block count: " << PS->getMaxInternalCount() << "\n"; + if (ShownFunctions && ShowIndirectCallTargets) { OS << "Statistics for indirect call sites profile:\n"; showValueSitesStats(OS, IPVK_IndirectCallTarget, VPStats[IPVK_IndirectCallTarget]); } + if (ShownFunctions && ShowMemOPSizes) { + OS << "Statistics for memory intrinsic calls sizes profile:\n"; + showValueSitesStats(OS, IPVK_MemOPSize, VPStats[IPVK_MemOPSize]); + } + if (ShowDetailedSummary) { OS << "Detailed summary:\n"; OS << "Total number of blocks: " << PS->getNumCounts() << "\n"; @@ -629,6 +649,10 @@ static int show_main(int argc, const char *argv[]) { cl::opt<bool> ShowIndirectCallTargets( "ic-targets", cl::init(false), cl::desc("Show indirect call site target values for shown functions")); + cl::opt<bool> ShowMemOPSizes( + "memop-sizes", cl::init(false), + cl::desc("Show the profiled sizes of the memory intrinsic calls " + "for shown functions")); cl::opt<bool> ShowDetailedSummary("detailed-summary", cl::init(false), cl::desc("Show detailed profile summary")); cl::list<uint32_t> DetailedSummaryCutoffs( @@ -667,8 +691,9 @@ static int show_main(int argc, const char *argv[]) { DetailedSummaryCutoffs.end()); if (ProfileKind == instr) return showInstrProfile(Filename, ShowCounts, ShowIndirectCallTargets, - ShowDetailedSummary, DetailedSummaryCutoffs, - ShowAllFunctions, ShowFunction, TextFormat, OS); + ShowMemOPSizes, ShowDetailedSummary, + DetailedSummaryCutoffs, ShowAllFunctions, + ShowFunction, TextFormat, OS); else return showSampleProfile(Filename, ShowCounts, ShowAllFunctions, ShowFunction, OS); |