summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerValueBitMap.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-09-15 04:36:45 +0000
committerKostya Serebryany <kcc@google.com>2016-09-15 04:36:45 +0000
commit53501784879cffea4154fcd187adc185ab05d72f (patch)
tree847c8968b470a8359b17f8e8d550d893a59aa827 /llvm/lib/Fuzzer/FuzzerValueBitMap.h
parent546d2a38205d86f451988ba5e489ce2e887bd932 (diff)
downloadbcm5719-llvm-53501784879cffea4154fcd187adc185ab05d72f.tar.gz
bcm5719-llvm-53501784879cffea4154fcd187adc185ab05d72f.zip
[libFuzzer] implement print_pcs with trace-pc-guard. Change the trace-pc-guard heuristic for 8-bit counters to look more like in AFL (not that it's provable better, but the existin test preferes this heuristic)
llvm-svn: 281577
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerValueBitMap.h')
-rw-r--r--llvm/lib/Fuzzer/FuzzerValueBitMap.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerValueBitMap.h b/llvm/lib/Fuzzer/FuzzerValueBitMap.h
index 2a917333e21..6f6ca116473 100644
--- a/llvm/lib/Fuzzer/FuzzerValueBitMap.h
+++ b/llvm/lib/Fuzzer/FuzzerValueBitMap.h
@@ -24,12 +24,16 @@ struct ValueBitMap {
// Clears all bits.
void Reset() { memset(Map, 0, sizeof(Map)); }
- // Computed a hash function of Value and sets the corresponding bit.
- inline void AddValue(uintptr_t Value) {
+ // Computes a hash function of Value and sets the corresponding bit.
+ // Returns true if the bit was changed from 0 to 1.
+ inline bool AddValue(uintptr_t Value) {
uintptr_t Idx = Value < kMapSizeInBits ? Value : Value % kMapSizeInBits;
uintptr_t WordIdx = Idx / kBitsInWord;
uintptr_t BitIdx = Idx % kBitsInWord;
- Map[WordIdx] |= 1UL << BitIdx;
+ uintptr_t Old = Map[WordIdx];
+ uintptr_t New = Old | (1UL << BitIdx);
+ Map[WordIdx] = New;
+ return New != Old;
}
// Merges 'Other' into 'this', clears 'Other',
OpenPOWER on IntegriCloud