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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user