]> granicus.if.org Git - llvm/commitdiff
[libFuzzer] Use long long to ensure 64 bits.
authorMarcos Pividori <mpividori@google.com>
Wed, 8 Feb 2017 00:03:31 +0000 (00:03 +0000)
committerMarcos Pividori <mpividori@google.com>
Wed, 8 Feb 2017 00:03:31 +0000 (00:03 +0000)
We should always use unsigned long long to ensure 64 bits. On Windows, unsigned
long is 4 bytes. This was the reason why value-profile-cmp4.test was failing on
Windows.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294390 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerTracePC.cpp
lib/Fuzzer/FuzzerValueBitMap.h
lib/Fuzzer/test/AbsNegAndConstant64Test.cpp

index ff1d494bafeeb2e5f5595d1a9a527acde5deda4e..661ad23a8e34edfe3591ef265e77b340258d01f6 100644 (file)
@@ -273,7 +273,7 @@ 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_popcountl(ArgXor) + 1; // [1,65]
+  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);
index 68dc3a9fc3ac10589a69ce253b2afc0e385750fc..600337ae407d4466c8cc6b3a3fff438f263ffd37 100644 (file)
@@ -68,7 +68,7 @@ struct ValueBitMap {
         Other.Map[i] = 0;
       }
       if (M)
-        Res += __builtin_popcountl(M);
+        Res += __builtin_popcountll(M);
     }
     NumBits = Res;
     return OldNumBits < NumBits;
index 577481431ae29411d7cc0411c466a282468aeb1e..69b0d59fb8eff432ddd5e62a33c0000b8f0f90e3 100644 (file)
@@ -14,7 +14,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   uint64_t y;
   memcpy(&x, Data, sizeof(x));
   memcpy(&y, Data + sizeof(x), sizeof(y));
-  if (labs(x) < 0 && y == 0xbaddcafedeadbeefUL) {
+  if (llabs(x) < 0 && y == 0xbaddcafedeadbeefULL) {
     printf("BINGO; Found the target, exiting; x = 0x%lx y 0x%lx\n", x, y);
     exit(1);
   }