<div dir="ltr">Broken by this patch <div><a href="http://lab.llvm.org:8011/builders/sanitizer-windows/builds/14792">http://lab.llvm.org:8011/builders/sanitizer-windows/builds/14792</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 5:48 PM, Kostya Serebryany via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kcc<br>
Date: Mon Jul 31 17:48:44 2017<br>
New Revision: 309646<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=309646&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=309646&view=rev</a><br>
Log:<br>
[libFuzzer] enable -fsanitize-coverage=pc-table for all tests<br>
<br>
Modified:<br>
    llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.cpp<br>
    llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.h<br>
    llvm/trunk/lib/Fuzzer/test/<wbr>CMakeLists.txt<br>
    llvm/trunk/lib/Fuzzer/test/<wbr>inline-8bit-counters.test<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.cpp?rev=309646&<wbr>r1=309645&r2=309646&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.cpp (original)<br>
+++ llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.cpp Mon Jul 31 17:48:44 2017<br>
@@ -72,7 +72,7 @@ void TracePC::HandlePCsInit(const uint8_<br>
   if (NumPCTables && ModulePCTable[NumPCTables - 1].Start == B) return;<br>
   assert(NumPCTables < sizeof(ModulePCTable) / sizeof(ModulePCTable[0]));<br>
   ModulePCTable[NumPCTables++] = {B, E};<br>
-  NumPCsInPCTables = E - B;<br>
+  NumPCsInPCTables += E - B;<br>
 }<br>
<br>
 void TracePC::HandleInit(uint32_t *Start, uint32_t *Stop) {<br>
@@ -95,26 +95,36 @@ void TracePC::HandleInit(uint32_t *Start<br>
<br>
 void TracePC::PrintModuleInfo() {<br>
   if (NumGuards) {<br>
-    Printf("INFO: Loaded %zd modules (%zd guards): ", NumModules, NumGuards);<br>
+    Printf("INFO: Loaded %zd modules   (%zd guards): ", NumModules, NumGuards);<br>
     for (size_t i = 0; i < NumModules; i++)<br>
-      Printf("[%p, %p), ", Modules[i].Start, Modules[i].Stop);<br>
+      Printf("%zd [%p, %p), ", Modules[i].Stop - Modules[i].Start,<br>
+             Modules[i].Start, Modules[i].Stop);<br>
     Printf("\n");<br>
   }<br>
   if (<wbr>NumModulesWithInline8bitCounte<wbr>rs) {<br>
-    Printf("INFO: Loaded %zd modules with %zd inline 8-bit counters: ",<br>
+    Printf("INFO: Loaded %zd modules   (%zd inline 8-bit counters): ",<br>
            NumModulesWithInline8bitCounte<wbr>rs, NumInline8bitCounters);<br>
     for (size_t i = 0; i < NumModulesWithInline8bitCounte<wbr>rs; i++)<br>
-      Printf("[%p, %p), ", ModuleCounters[i].Start, ModuleCounters[i].Stop);<br>
+      Printf("%zd [%p, %p), ", ModuleCounters[i].Stop - ModuleCounters[i].Start,<br>
+             ModuleCounters[i].Start, ModuleCounters[i].Stop);<br>
     Printf("\n");<br>
   }<br>
   if (NumPCTables) {<br>
-    Printf("INFO: Loaded %zd PC tables,   %zd PCs: ", NumPCTables,<br>
+    Printf("INFO: Loaded %zd PC tables (%zd PCs): ", NumPCTables,<br>
            NumPCsInPCTables);<br>
     for (size_t i = 0; i < NumPCTables; i++) {<br>
-      Printf("[%p,%p), ", ModulePCTable[i].Start, ModulePCTable[i].Stop,<br>
-             ModulePCTable[i].Stop - ModulePCTable[i].Start);<br>
+      Printf("%zd [%p,%p), ", ModulePCTable[i].Stop - ModulePCTable[i].Start,<br>
+             ModulePCTable[i].Start, ModulePCTable[i].Stop);<br>
     }<br>
     Printf("\n");<br>
+<br>
+    if ((NumGuards && NumGuards != NumPCsInPCTables) ||<br>
+        (NumInline8bitCounters && NumInline8bitCounters != NumPCsInPCTables)) {<br>
+      Printf("ERROR: The size of coverage PC tables does not match the"<br>
+             " number of instrumented PCs. This might be a bug in the compiler,"<br>
+             " please contact the libFuzzer developers.\n");<br>
+      _Exit(1);<br>
+    }<br>
   }<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.h?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.h?rev=309646&r1=<wbr>309645&r2=309646&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.h (original)<br>
+++ llvm/trunk/lib/Fuzzer/<wbr>FuzzerTracePC.h Mon Jul 31 17:48:44 2017<br>
@@ -86,7 +86,8 @@ class TracePC {<br>
<br>
   void ResetMaps() {<br>
     ValueProfileMap.Reset();<br>
-    memset(Counters(), 0, GetNumPCs());<br>
+    if (NumModules)<br>
+      memset(Counters(), 0, GetNumPCs());<br>
     ClearExtraCounters();<br>
     ClearInlineCounters();<br>
   }<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/test/<wbr>CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/CMakeLists.txt?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Fuzzer/<wbr>test/CMakeLists.txt?rev=<wbr>309646&r1=309645&r2=309646&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/test/<wbr>CMakeLists.txt (original)<br>
+++ llvm/trunk/lib/Fuzzer/test/<wbr>CMakeLists.txt Mon Jul 31 17:48:44 2017<br>
@@ -15,7 +15,7 @@ foreach (VARNAME ${variables_to_filter})<br>
 endforeach()<br>
<br>
 # Enable the coverage instrumentation (it is disabled for the Fuzzer lib).<br>
-set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fsanitize-coverage=trace-pc-<wbr>guard,indirect-calls,trace-<wbr>cmp,trace-div,trace-gep -gline-tables-only")<br>
+set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fsanitize-coverage=trace-pc-<wbr>guard,indirect-calls,trace-<wbr>cmp,trace-div,trace-gep,pc-<wbr>table -gline-tables-only")<br>
<br>
 if(MSVC)<br>
   # For tests use the CRT specified for release build<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/test/<wbr>inline-8bit-counters.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/inline-8bit-counters.test?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Fuzzer/<wbr>test/inline-8bit-counters.<wbr>test?rev=309646&r1=309645&r2=<wbr>309646&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/test/<wbr>inline-8bit-counters.test (original)<br>
+++ llvm/trunk/lib/Fuzzer/test/<wbr>inline-8bit-counters.test Mon Jul 31 17:48:44 2017<br>
@@ -1,4 +1,4 @@<br>
 REQUIRES: linux<br>
-CHECK: INFO: Loaded 1 modules with {{.*}} inline 8-bit counters<br>
+CHECK: INFO: Loaded 1 modules ({{.*}} inline 8-bit counters)<br>
 CHECK: BINGO<br>
 RUN: not LLVMFuzzer-SimpleTest-<wbr>Inline8bitCounters -runs=1000000 -seed=1 2>&1 | FileCheck %s<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>