diff options
author | Diego Novillo <dnovillo@google.com> | 2015-10-08 19:40:37 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2015-10-08 19:40:37 +0000 |
commit | aae1ed8e08236a8f99b8fca690db7f954f15c031 (patch) | |
tree | 944a813f18347274fde4a275a166ddf5d346c730 /llvm/tools/llvm-profdata/llvm-profdata.cpp | |
parent | eb84ce8bd17f7b2516a15aca7d37a768f0cf10f6 (diff) | |
download | bcm5719-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/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index fdf22c3642f..382ac908da4 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -77,13 +77,19 @@ static void mergeSampleProfile(const cl::list<std::string> &Inputs, auto Writer = std::move(WriterOrErr.get()); StringMap<FunctionSamples> ProfileMap; + SmallVector<std::unique_ptr<sampleprof::SampleProfileReader>, 5> Readers; for (const auto &Filename : Inputs) { auto ReaderOrErr = SampleProfileReader::create(Filename, getGlobalContext()); if (std::error_code EC = ReaderOrErr.getError()) exitWithError(EC.message(), Filename); - auto Reader = std::move(ReaderOrErr.get()); + // We need to keep the readers around until after all the files are + // read so that we do not lose the function names stored in each + // reader's memory. The function names are needed to write out the + // merged profile map. + Readers.push_back(std::move(ReaderOrErr.get())); + const auto Reader = Readers.back().get(); if (std::error_code EC = Reader->read()) exitWithError(EC.message(), Filename); |