diff options
author | Diego Novillo <dnovillo@google.com> | 2015-10-09 17:54:24 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2015-10-09 17:54:24 +0000 |
commit | a7f1e8ef830e2b8e17fc9eee67ed2454ab9b5041 (patch) | |
tree | 3d160022dd8aeee9e681c995350148945de5bfa1 /llvm/lib/ProfileData/SampleProfWriter.cpp | |
parent | 26c6e641591a0f93746038f938ecb00e600ddf1d (diff) | |
download | bcm5719-llvm-a7f1e8ef830e2b8e17fc9eee67ed2454ab9b5041.tar.gz bcm5719-llvm-a7f1e8ef830e2b8e17fc9eee67ed2454ab9b5041.zip |
Add inline stack streaming to binary sample profiles.
With this patch we can now read and write inline stacks in sample
profiles to the binary encoded profiles.
In a subsequent patch, I will add a string table to the binary encoding.
Right now function names are emitted as strings every time we find them.
This is too bloated and will produce large files in applications with
lots of inlining.
llvm-svn: 249861
Diffstat (limited to 'llvm/lib/ProfileData/SampleProfWriter.cpp')
-rw-r--r-- | llvm/lib/ProfileData/SampleProfWriter.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp index e6a4d7d1321..6be884b13e0 100644 --- a/llvm/lib/ProfileData/SampleProfWriter.cpp +++ b/llvm/lib/ProfileData/SampleProfWriter.cpp @@ -84,14 +84,13 @@ SampleProfileWriterBinary::SampleProfileWriterBinary(StringRef F, /// \returns true if the samples were written successfully, false otherwise. bool SampleProfileWriterBinary::write(StringRef FName, const FunctionSamples &S) { - if (S.empty()) - return true; - OS << FName; encodeULEB128(0, OS); encodeULEB128(S.getTotalSamples(), OS); encodeULEB128(S.getHeadSamples(), OS); encodeULEB128(S.getBodySamples().size(), OS); + + // Emit all the body samples. for (const auto &I : S.getBodySamples()) { LineLocation Loc = I.first; const SampleRecord &Sample = I.second; @@ -108,6 +107,16 @@ bool SampleProfileWriterBinary::write(StringRef FName, } } + // Recursively emit all the callsite samples. + encodeULEB128(S.getCallsiteSamples().size(), OS); + for (const auto &J : S.getCallsiteSamples()) { + CallsiteLocation Loc = J.first; + const FunctionSamples &CalleeSamples = J.second; + encodeULEB128(Loc.LineOffset, OS); + encodeULEB128(Loc.Discriminator, OS); + write(Loc.CalleeName, CalleeSamples); + } + return true; } |