diff options
author | David Blaikie <dblaikie@gmail.com> | 2017-07-21 21:41:15 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2017-07-21 21:41:15 +0000 |
commit | b8cc0544d258962ba32c2554e054d69996fe1f84 (patch) | |
tree | 77fc4b3fe0f4c5383cf1c09e3fe6cac16708376c /llvm/lib/ProfileData/InstrProf.cpp | |
parent | 38c02bc7f5787be91a5b095fd84c7628288185a1 (diff) | |
download | bcm5719-llvm-b8cc0544d258962ba32c2554e054d69996fe1f84.tar.gz bcm5719-llvm-b8cc0544d258962ba32c2554e054d69996fe1f84.zip |
[ProfData] Detect if zlib is available
As discussed on [1], if the profile is compressed and llvm-profdata is not built with zlib support, the error message is not informative. Give a better error message if zlib is not available.
[1] http://lists.llvm.org/pipermail/llvm-dev/2017-July/115571.html
Reviewers: davidxl, dblaikie
Differential Revision: https://reviews.llvm.org/D35586
llvm-svn: 308789
Diffstat (limited to 'llvm/lib/ProfileData/InstrProf.cpp')
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 48c1643cb13..a732bedc6fa 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -111,6 +111,8 @@ static std::string getInstrProfErrString(instrprof_error Err) { return "Failed to uncompress data (zlib)"; case instrprof_error::empty_raw_profile: return "Empty raw profile file"; + case instrprof_error::zlib_unavailable: + return "Profile uses zlib compression but the profile reader was built without zlib support"; } llvm_unreachable("A value of instrprof_error has no message."); } @@ -430,6 +432,9 @@ Error readPGOFuncNameStrings(StringRef NameStrings, InstrProfSymtab &Symtab) { SmallString<128> UncompressedNameStrings; StringRef NameStrings; if (isCompressed) { + if (!llvm::zlib::isAvailable()) + return make_error<InstrProfError>(instrprof_error::zlib_unavailable); + StringRef CompressedNameStrings(reinterpret_cast<const char *>(P), CompressedSize); if (Error E = |