[compiler-rt] r319190 - [LibFuzzer] Improve comments on `CounterToFeature()` function.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 09:41:58 PST 2017


Author: delcypher
Date: Tue Nov 28 09:41:58 2017
New Revision: 319190

URL: http://llvm.org/viewvc/llvm-project?rev=319190&view=rev
Log:
[LibFuzzer] Improve comments on `CounterToFeature()` function.

This is based on discussion in https://reviews.llvm.org/D40376 .

The comments try to explain the reason for the current implementation
and note that it might change in the future, so clients should not
rely on this particular implementation.

Differential Revision: https://reviews.llvm.org/D40565

Modified:
    compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.h

Modified: compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.h?rev=319190&r1=319189&r2=319190&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.h (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.h Tue Nov 28 09:41:58 2017
@@ -196,9 +196,20 @@ void ForEachNonZeroByte(const uint8_t *B
       Handle8bitCounter(FirstFeature, P - Begin, V);
 }
 
-// Given a non-zero Counters returns a number in [0,7].
+// Given a non-zero Counter returns a number in the range [0,7].
 template<class T>
 unsigned CounterToFeature(T Counter) {
+    // Returns a feature number by placing Counters into buckets as illustrated
+    // below.
+    //
+    // Counter bucket: [1] [2] [3] [4-7] [8-15] [16-31] [32-127] [128+]
+    // Feature number:  0   1   2    3     4       5       6       7
+    //
+    // This is a heuristic taken from AFL (see
+    // http://lcamtuf.coredump.cx/afl/technical_details.txt).
+    //
+    // This implementation may change in the future so clients should
+    // not rely on it.
     assert(Counter);
     unsigned Bit = 0;
     /**/ if (Counter >= 128) Bit = 7;




More information about the llvm-commits mailing list