OSDN Git Service

[libFuzzer] collect 64 states for value profile, not 65
authorKostya Serebryany <kcc@google.com>
Tue, 23 Aug 2016 23:37:37 +0000 (23:37 +0000)
committerKostya Serebryany <kcc@google.com>
Tue, 23 Aug 2016 23:37:37 +0000 (23:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279588 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerTraceState.cpp

index 71ff499..4192ceb 100644 (file)
@@ -576,8 +576,12 @@ static void AddValueForStrcmp(void *caller_pc, const char *s1, const char *s2,
 
 __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