[libFuzzer] collect 64 states for value profile, not 65
llvm-svn: 279588
diff --git a/llvm/lib/Fuzzer/FuzzerTraceState.cpp b/llvm/lib/Fuzzer/FuzzerTraceState.cpp
index 71ff499..4192ceb 100644
--- a/llvm/lib/Fuzzer/FuzzerTraceState.cpp
+++ b/llvm/lib/Fuzzer/FuzzerTraceState.cpp
@@ -576,8 +576,12 @@
__attribute__((target("popcnt")))
static void AddValueForCmp(void *PCptr, uint64_t Arg1, uint64_t Arg2) {
+ if (Arg1 == Arg2)
+ return;
uintptr_t PC = reinterpret_cast<uintptr_t>(PCptr);
- VP.AddValue((PC & 4095) | (__builtin_popcountl(Arg1 ^ Arg2) << 12));
+ uint64_t ArgDistance = __builtin_popcountl(Arg1 ^ Arg2) - 1; // [0,63]
+ uintptr_t Idx = (PC & 4095) | (ArgDistance << 12);
+ VP.AddValue(Idx);
}
} // namespace fuzzer