summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/SampleProfWriter.cpp
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2015-10-08 19:40:37 +0000
committerDiego Novillo <dnovillo@google.com>2015-10-08 19:40:37 +0000
commitaae1ed8e08236a8f99b8fca690db7f954f15c031 (patch)
tree944a813f18347274fde4a275a166ddf5d346c730 /llvm/lib/ProfileData/SampleProfWriter.cpp
parenteb84ce8bd17f7b2516a15aca7d37a768f0cf10f6 (diff)
downloadbcm5719-llvm-aae1ed8e08236a8f99b8fca690db7f954f15c031.tar.gz
bcm5719-llvm-aae1ed8e08236a8f99b8fca690db7f954f15c031.zip
Re-apply r249644: Handle inline stacks in gcov-encoded sample profiles.
This fixes memory allocation problems by making the merge operation keep the profile readers around until the merged profile has been emitted. This is needed to prevent the inlined function names to disappear from the function profiles. Since all the names are kept as references, once the reader disappears, the names are also deallocated. Additionally, XFAIL on big-endian architectures. The test case uses a gcov file generated on a little-endian system. llvm-svn: 249724
Diffstat (limited to 'llvm/lib/ProfileData/SampleProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/SampleProfWriter.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index c95267ad976..e6a4d7d1321 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -31,15 +31,15 @@ using namespace llvm;
/// \brief Write samples to a text file.
bool SampleProfileWriterText::write(StringRef FName, const FunctionSamples &S) {
- if (S.empty())
- return true;
-
- OS << FName << ":" << S.getTotalSamples() << ":" << S.getHeadSamples()
- << "\n";
+ OS << FName << ":" << S.getTotalSamples();
+ if (Indent == 0)
+ OS << ":" << S.getHeadSamples();
+ OS << "\n";
for (const auto &I : S.getBodySamples()) {
LineLocation Loc = I.first;
const SampleRecord &Sample = I.second;
+ OS.indent(Indent + 1);
if (Loc.Discriminator == 0)
OS << Loc.LineOffset << ": ";
else
@@ -52,6 +52,19 @@ bool SampleProfileWriterText::write(StringRef FName, const FunctionSamples &S) {
OS << "\n";
}
+ Indent += 1;
+ for (const auto &I : S.getCallsiteSamples()) {
+ CallsiteLocation Loc = I.first;
+ const FunctionSamples &CalleeSamples = I.second;
+ OS.indent(Indent);
+ if (Loc.Discriminator == 0)
+ OS << Loc.LineOffset << ": ";
+ else
+ OS << Loc.LineOffset << "." << Loc.Discriminator << ": ";
+ write(Loc.CalleeName, CalleeSamples);
+ }
+ Indent -= 1;
+
return true;
}
OpenPOWER on IntegriCloud