diff options
author | Rong Xu <xur@google.com> | 2016-10-19 22:51:17 +0000 |
---|---|---|
committer | Rong Xu <xur@google.com> | 2016-10-19 22:51:17 +0000 |
commit | 2c684cfd94b0979e919b62d9d81ccd37c10bdba1 (patch) | |
tree | 580b1833d951cb7e3014ba553dd7d938d8137037 /llvm/lib/ProfileData | |
parent | 66cc2d52109354871fe6f5079e4577db17b6867d (diff) | |
download | bcm5719-llvm-2c684cfd94b0979e919b62d9d81ccd37c10bdba1.tar.gz bcm5719-llvm-2c684cfd94b0979e919b62d9d81ccd37c10bdba1.zip |
[PGO] Fix bogus warning for merging empty llvm profile file
Profile runtime can generate an empty raw profile (when there is no function in
the shared library). This empty profile is treated as a text format profile. A
test format profile without the flag of "#IR" is thought to be a clang
generated profile. So in llvm profile merging, we will get a bogus warning of
"Merge IR generated profile with Clang generated profile."
The fix here is to skip the empty profile (when the buffer size is 0) for
profile merge.
Reviewers: vsk, davidxl
Differential Revision: http://reviews.llvm.org/D25687
llvm-svn: 284659
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProfReader.cpp | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index dac91950183..b512f543e95 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -70,6 +70,8 @@ std::string getInstrProfErrString(instrprof_error Err) { return "Failed to compress data (zlib)"; case instrprof_error::uncompress_failed: return "Failed to uncompress data (zlib)"; + case instrprof_error::empty_raw_profile: + return "Empty raw profile file"; } llvm_unreachable("A value of instrprof_error has no message."); } diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 81c13b35ce3..ed927a98604 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -46,6 +46,9 @@ InstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer) { if (Buffer->getBufferSize() > std::numeric_limits<unsigned>::max()) return make_error<InstrProfError>(instrprof_error::too_large); + if (Buffer->getBufferSize() == 0) + return make_error<InstrProfError>(instrprof_error::empty_raw_profile); + std::unique_ptr<InstrProfReader> Result; // Create the reader. if (IndexedInstrProfReader::hasFormat(*Buffer)) |