diff options
author | Wei Mi <wmi@google.com> | 2018-06-11 22:40:43 +0000 |
---|---|---|
committer | Wei Mi <wmi@google.com> | 2018-06-11 22:40:43 +0000 |
commit | a0c0857e7a2398237d00a13ad9ac7078c0148578 (patch) | |
tree | 7ed375920f8708f1cc9ef6ca32651cb7c166abef /llvm/tools/llvm-profdata/llvm-profdata.cpp | |
parent | 19b22d406d5d37428cb62f0f8b0de79afbe99b63 (diff) | |
download | bcm5719-llvm-a0c0857e7a2398237d00a13ad9ac7078c0148578.tar.gz bcm5719-llvm-a0c0857e7a2398237d00a13ad9ac7078c0148578.zip |
[SampleFDO] Add a new compact binary format for sample profile.
Name table occupies a big chunk of size in current binary format sample profile.
In order to reduce its size, the patch changes the sample writer/reader to
save/restore MD5Hash of names in the name table. Sample annotation phase will
also use MD5Hash of name to query samples accordingly.
Experiment shows compact binary format can reduce the size of sample profile by
2/3 compared with binary format generally.
Differential Revision: https://reviews.llvm.org/D47955
llvm-svn: 334447
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index cb043837134..842f30fc3e9 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -34,7 +34,13 @@ using namespace llvm; -enum ProfileFormat { PF_None = 0, PF_Text, PF_Binary, PF_GCC }; +enum ProfileFormat { + PF_None = 0, + PF_Text, + PF_Compact_Binary, + PF_GCC, + PF_Raw_Binary +}; static void warn(Twine Message, std::string Whence = "", std::string Hint = "") { @@ -236,7 +242,8 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, if (OutputFilename.compare("-") == 0) exitWithError("Cannot write indexed profdata format to stdout."); - if (OutputFormat != PF_Binary && OutputFormat != PF_Text) + if (OutputFormat != PF_Raw_Binary && OutputFormat != PF_Compact_Binary && + OutputFormat != PF_Text) exitWithError("Unknown format is specified."); std::error_code EC; @@ -316,8 +323,8 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, } static sampleprof::SampleProfileFormat FormatMap[] = { - sampleprof::SPF_None, sampleprof::SPF_Text, sampleprof::SPF_Binary, - sampleprof::SPF_GCC}; + sampleprof::SPF_None, sampleprof::SPF_Text, sampleprof::SPF_Compact_Binary, + sampleprof::SPF_GCC, sampleprof::SPF_Raw_Binary}; static void mergeSampleProfile(const WeightedFileVector &Inputs, StringRef OutputFilename, @@ -464,11 +471,14 @@ static int merge_main(int argc, const char *argv[]) { cl::values(clEnumVal(instr, "Instrumentation profile (default)"), clEnumVal(sample, "Sample profile"))); cl::opt<ProfileFormat> OutputFormat( - cl::desc("Format of output profile"), cl::init(PF_Binary), - cl::values(clEnumValN(PF_Binary, "binary", "Binary encoding (default)"), - clEnumValN(PF_Text, "text", "Text encoding"), - clEnumValN(PF_GCC, "gcc", - "GCC encoding (only meaningful for -sample)"))); + cl::desc("Format of output profile"), cl::init(PF_Raw_Binary), + cl::values( + clEnumValN(PF_Raw_Binary, "binary", "Binary encoding (default)"), + clEnumValN(PF_Compact_Binary, "compbinary", + "Compact binary encoding (default)"), + clEnumValN(PF_Text, "text", "Text encoding"), + clEnumValN(PF_GCC, "gcc", + "GCC encoding (only meaningful for -sample)"))); cl::opt<bool> OutputSparse("sparse", cl::init(false), cl::desc("Generate a sparse profile (only meaningful for -instr)")); cl::opt<unsigned> NumThreads( |