Skip to content

Commit 5a53567

Browse files
author
Marcos Pividori
committedFeb 8, 2017
[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 llvm-svn: 294390
1 parent 2a318a1 commit 5a53567

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed
 

‎llvm/lib/Fuzzer/FuzzerTracePC.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ ATTRIBUTE_TARGET_POPCNT ALWAYS_INLINE
273273
ATTRIBUTE_NO_SANITIZE_ALL
274274
void TracePC::HandleCmp(uintptr_t PC, T Arg1, T Arg2) {
275275
uint64_t ArgXor = Arg1 ^ Arg2;
276-
uint64_t ArgDistance = __builtin_popcountl(ArgXor) + 1; // [1,65]
276+
uint64_t ArgDistance = __builtin_popcountll(ArgXor) + 1; // [1,65]
277277
uintptr_t Idx = ((PC & 4095) + 1) * ArgDistance;
278278
if (sizeof(T) == 4)
279279
TORC4.Insert(ArgXor, Arg1, Arg2);

‎llvm/lib/Fuzzer/FuzzerValueBitMap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct ValueBitMap {
6868
Other.Map[i] = 0;
6969
}
7070
if (M)
71-
Res += __builtin_popcountl(M);
71+
Res += __builtin_popcountll(M);
7272
}
7373
NumBits = Res;
7474
return OldNumBits < NumBits;

‎llvm/lib/Fuzzer/test/AbsNegAndConstant64Test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
1414
uint64_t y;
1515
memcpy(&x, Data, sizeof(x));
1616
memcpy(&y, Data + sizeof(x), sizeof(y));
17-
if (labs(x) < 0 && y == 0xbaddcafedeadbeefUL) {
17+
if (llabs(x) < 0 && y == 0xbaddcafedeadbeefULL) {
1818
printf("BINGO; Found the target, exiting; x = 0x%lx y 0x%lx\n", x, y);
1919
exit(1);
2020
}

0 commit comments

Comments
 (0)
Please sign in to comment.