Index: llvm/trunk/include/llvm/ProfileData/InstrProf.h =================================================================== --- llvm/trunk/include/llvm/ProfileData/InstrProf.h +++ llvm/trunk/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) { Index: llvm/trunk/lib/ProfileData/InstrProf.cpp =================================================================== --- llvm/trunk/lib/ProfileData/InstrProf.cpp +++ llvm/trunk/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,9 @@ 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 = Index: llvm/trunk/test/tools/llvm-profdata/nocompress.test =================================================================== --- llvm/trunk/test/tools/llvm-profdata/nocompress.test +++ llvm/trunk/test/tools/llvm-profdata/nocompress.test @@ -0,0 +1,15 @@ +You need a checkout of clang with compiler-rt to generate the +binary file here. These shell commands can be used to regenerate +it. +$ SRC=path/to/llvm +$ CFE=$SRC/tools/clang +$ TESTDIR=$SRC/test/tools/llvm-profdata +$ CFE_TESTDIR=$CFE/test/Profile +$ clang -o a.out -fprofile-instr-generate $CFE_TESTDIR/c-general.c +$ LLVM_PROFILE_FILE=$TESTDIR/Inputs/compressed.profraw ./a.out + +RUN: not llvm-profdata show %p/Inputs/compressed.profraw -o %t 2>&1 | FileCheck %s + +REQUIRES: nozlib + +CHECK: error: {{.*}} Profile uses zlib compression but the profile reader was built without zlib support