From b8cc0544d258962ba32c2554e054d69996fe1f84 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 21 Jul 2017 21:41:15 +0000 Subject: [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 --- llvm/lib/ProfileData/InstrProf.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/ProfileData/InstrProf.cpp') 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(instrprof_error::zlib_unavailable); + StringRef CompressedNameStrings(reinterpret_cast(P), CompressedSize); if (Error E = -- cgit v1.2.3