<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 19, 2017 at 2:35 PM Wei-Ren Chen via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">chenwj updated this revision to Diff 107382.<br>
chenwj added a comment.<br>
<br>
@dblaikie I upload the profile data and test case. However, the error message I check including the full path of the profile data. Any idea on how can I improve this?<br>
<br>
<br>
<a href="https://reviews.llvm.org/D35586" rel="noreferrer" target="_blank">https://reviews.llvm.org/D35586</a><br>
<br>
Files:<br>
  include/llvm/ProfileData/InstrProf.h<br>
  lib/ProfileData/InstrProf.cpp<br>
  test/tools/llvm-profdata/Inputs/compressed.profraw<br>
  test/tools/llvm-profdata/nocompress.test<br>
<br>
<br>
Index: test/tools/llvm-profdata/nocompress.test<br>
===================================================================<br>
--- /dev/null<br>
+++ test/tools/llvm-profdata/nocompress.test<br>
@@ -0,0 +1,5 @@<br>
+RUN: not llvm-profdata show %p/Inputs/compressed.profraw -o %t 2>&1 | FileCheck %s<br>
+<br>
+REQUIRES: nozlib<br>
+<br>
+CHECK: error: /Users/chenwj/Projects/llvm/test/tools/llvm-profdata/Inputs/compressed.profraw: Profile uses zlib compression but the profile reader was built without zlib support<br></blockquote><div><br>FileCheck supports regex:<br><br>CHECK: error: {{.*}}compressed.profraw: Profile uses ...<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Index: lib/ProfileData/InstrProf.cpp<br>
===================================================================<br>
--- lib/ProfileData/InstrProf.cpp<br>
+++ lib/ProfileData/InstrProf.cpp<br>
@@ -111,6 +111,8 @@<br>
     return "Failed to uncompress data (zlib)";<br>
   case instrprof_error::empty_raw_profile:<br>
     return "Empty raw profile file";<br>
+  case instrprof_error::zlib_unavailable:<br>
+    return "Profile uses zlib compression but the profile reader was built without zlib support";<br>
   }<br>
   llvm_unreachable("A value of instrprof_error has no message.");<br>
 }<br>
@@ -430,6 +432,9 @@<br>
     SmallString<128> UncompressedNameStrings;<br>
     StringRef NameStrings;<br>
     if (isCompressed) {<br>
+      if (!llvm::zlib::isAvailable())<br>
+        return make_error<InstrProfError>(instrprof_error::zlib_unavailable);<br>
+<br>
       StringRef CompressedNameStrings(reinterpret_cast<const char *>(P),<br>
                                       CompressedSize);<br>
       if (Error E =<br>
Index: include/llvm/ProfileData/InstrProf.h<br>
===================================================================<br>
--- include/llvm/ProfileData/InstrProf.h<br>
+++ include/llvm/ProfileData/InstrProf.h<br>
@@ -295,7 +295,8 @@<br>
   value_site_count_mismatch,<br>
   compress_failed,<br>
   uncompress_failed,<br>
-  empty_raw_profile<br>
+  empty_raw_profile,<br>
+  zlib_unavailable<br>
 };<br>
<br>
 inline std::error_code make_error_code(instrprof_error E) {<br>
<br>
<br>
</blockquote></div></div>