[PATCH] D35586: [ProfData] Detect if zlib is available
Wei-Ren Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 16:17:37 PDT 2017
chenwj created this revision.
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
https://reviews.llvm.org/D35586
Files:
include/llvm/ProfileData/InstrProf.h
lib/ProfileData/InstrProf.cpp
Index: lib/ProfileData/InstrProf.cpp
===================================================================
--- lib/ProfileData/InstrProf.cpp
+++ lib/ProfileData/InstrProf.cpp
@@ -111,6 +111,8 @@
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,10 @@
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 =
Index: include/llvm/ProfileData/InstrProf.h
===================================================================
--- include/llvm/ProfileData/InstrProf.h
+++ include/llvm/ProfileData/InstrProf.h
@@ -295,7 +295,8 @@
value_site_count_mismatch,
compress_failed,
uncompress_failed,
- empty_raw_profile
+ empty_raw_profile,
+ zlib_unavailable
};
inline std::error_code make_error_code(instrprof_error E) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35586.107199.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170718/0f644e7e/attachment.bin>
More information about the llvm-commits
mailing list