[llvm] r294390 - [libFuzzer] Use long long to ensure 64 bits.
Marcos Pividori via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 7 16:03:32 PST 2017
Author: mpividori
Date: Tue Feb 7 18:03:31 2017
New Revision: 294390
URL: http://llvm.org/viewvc/llvm-project?rev=294390&view=rev
Log:
[libFuzzer] Use long long to ensure 64 bits.
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
Modified:
llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h
llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp?rev=294390&r1=294389&r2=294390&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp Tue Feb 7 18:03:31 2017
@@ -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);
Modified: llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h?rev=294390&r1=294389&r2=294390&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h Tue Feb 7 18:03:31 2017
@@ -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;
Modified: llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp?rev=294390&r1=294389&r2=294390&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp (original)
+++ llvm/trunk/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp Tue Feb 7 18:03:31 2017
@@ -14,7 +14,7 @@ extern "C" int LLVMFuzzerTestOneInput(co
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);
}
More information about the llvm-commits
mailing list