diff options
author | Kostya Serebryany <kcc@google.com> | 2018-08-02 00:24:49 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2018-08-02 00:24:49 +0000 |
commit | cedebd594083a54cfb0a0b766fd000b6f11216fa (patch) | |
tree | f03e68bac496873b83b42b744f4d30d8cf107e82 /compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | |
parent | 994068268dd6a26c678afde549054989bce6ed89 (diff) | |
download | bcm5719-llvm-cedebd594083a54cfb0a0b766fd000b6f11216fa.tar.gz bcm5719-llvm-cedebd594083a54cfb0a0b766fd000b6f11216fa.zip |
[libFuzzer] use absolute distance in addition to the hamming distance in value profiling; our A/B testing have (somewhat weak) indication that this provides an additional signal for corpus expansion
llvm-svn: 338661
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerTracePC.cpp')
-rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp index 29ffc8e34fc..37b32b76ae1 100644 --- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp @@ -401,20 +401,15 @@ ATTRIBUTE_TARGET_POPCNT ALWAYS_INLINE ATTRIBUTE_NO_SANITIZE_ALL void TracePC::HandleCmp(uintptr_t PC, T Arg1, T Arg2) { uint64_t ArgXor = Arg1 ^ Arg2; - uint64_t ArgDistance = __builtin_popcountll(ArgXor) + 1; // [1,65] - uintptr_t Idx = ((PC & 4095) + 1) * ArgDistance; if (sizeof(T) == 4) TORC4.Insert(ArgXor, Arg1, Arg2); else if (sizeof(T) == 8) TORC8.Insert(ArgXor, Arg1, Arg2); - // TODO: remove these flags and instead use all metrics at once. - if (UseValueProfileMask & 1) - ValueProfileMap.AddValue(Idx); - if (UseValueProfileMask & 2) - ValueProfileMap.AddValue( - PC * 64 + (Arg1 == Arg2 ? 0 : __builtin_clzll(Arg1 - Arg2) + 1)); - if (UseValueProfileMask & 4) // alternative way to use the hamming distance - ValueProfileMap.AddValue(PC * 64 + ArgDistance); + uint64_t HammingDistance = __builtin_popcountll(ArgXor); // [0,64] + uint64_t AbsoluteDistance = + (Arg1 == Arg2 ? 0 : __builtin_clzll(Arg1 - Arg2) + 1); + ValueProfileMap.AddValue(PC * 128 + HammingDistance); + ValueProfileMap.AddValue(PC * 128 + 64 + AbsoluteDistance); } static size_t InternalStrnlen(const char *S, size_t MaxLen) { |