summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-profdata
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2019-09-20 23:24:50 +0000
committerWei Mi <wmi@google.com>2019-09-20 23:24:50 +0000
commitf118852046a1d255ed8c65c6b5db320e8cea53a0 (patch)
treeb35a22fbe1d944338582a4fe4a102de3654c2606 /llvm/tools/llvm-profdata
parent6c0894b58ac8cbf12383f18789ac5a161a18f141 (diff)
downloadbcm5719-llvm-f118852046a1d255ed8c65c6b5db320e8cea53a0.tar.gz
bcm5719-llvm-f118852046a1d255ed8c65c6b5db320e8cea53a0.zip
[SampleFDO] Expose an interface to return the size of a section or the size
of the profile for profile in ExtBinary format. Sometimes we want to limit the size of the profile by stripping some functions with low sample count or by stripping some function names with small text size from profile symbol list. That requires the profile reader to have the interfaces returning the size of a section or the size of total profile. The patch add those interfaces. At the same time, add some dump facility to show the size of each section. llvm-svn: 372439
Diffstat (limited to 'llvm/tools/llvm-profdata')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 4f825dfb5b8..2b1205b950f 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -982,10 +982,21 @@ static int showInstrProfile(const std::string &Filename, bool ShowCounts,
return 0;
}
+static void showSectionInfo(sampleprof::SampleProfileReader *Reader,
+ raw_fd_ostream &OS) {
+ if (!Reader->dumpSectionInfo(OS)) {
+ WithColor::warning() << "-show-sec-info-only is only supported for "
+ << "sample profile in extbinary format and is "
+ << "ignored for other formats.\n";
+ return;
+ }
+}
+
static int showSampleProfile(const std::string &Filename, bool ShowCounts,
bool ShowAllFunctions,
const std::string &ShowFunction,
- bool ShowProfileSymbolList, raw_fd_ostream &OS) {
+ bool ShowProfileSymbolList,
+ bool ShowSectionInfoOnly, raw_fd_ostream &OS) {
using namespace sampleprof;
LLVMContext Context;
auto ReaderOrErr = SampleProfileReader::create(Filename, Context);
@@ -993,6 +1004,12 @@ static int showSampleProfile(const std::string &Filename, bool ShowCounts,
exitWithErrorCode(EC, Filename);
auto Reader = std::move(ReaderOrErr.get());
+
+ if (ShowSectionInfoOnly) {
+ showSectionInfo(Reader.get(), OS);
+ return 0;
+ }
+
if (std::error_code EC = Reader->read())
exitWithErrorCode(EC, Filename);
@@ -1062,6 +1079,11 @@ static int show_main(int argc, const char *argv[]) {
cl::opt<bool> ShowProfileSymbolList(
"show-prof-sym-list", cl::init(false),
cl::desc("Show profile symbol list if it exists in the profile. "));
+ cl::opt<bool> ShowSectionInfoOnly(
+ "show-sec-info-only", cl::init(false),
+ cl::desc("Show the information of each section in the sample profile. "
+ "The flag is only usable when the sample profile is in "
+ "extbinary format"));
cl::ParseCommandLineOptions(argc, argv, "LLVM profile data summary\n");
@@ -1090,7 +1112,8 @@ static int show_main(int argc, const char *argv[]) {
OnlyListBelow, ShowFunction, TextFormat, OS);
else
return showSampleProfile(Filename, ShowCounts, ShowAllFunctions,
- ShowFunction, ShowProfileSymbolList, OS);
+ ShowFunction, ShowProfileSymbolList,
+ ShowSectionInfoOnly, OS);
}
int main(int argc, const char *argv[]) {
OpenPOWER on IntegriCloud