diff options
| author | Kostya Serebryany <kcc@google.com> | 2016-09-23 00:22:46 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2016-09-23 00:22:46 +0000 |
| commit | d28099de5db44eb3f9f115ab60a11d9d4f9f0ecf (patch) | |
| tree | 8f940407af3e8dfbcbe9889a1cb75de4e2babf74 /llvm/lib/Fuzzer/FuzzerValueBitMap.h | |
| parent | 5b16d931dc25d6318d4751ce4f4c0b346c86a562 (diff) | |
| download | bcm5719-llvm-d28099de5db44eb3f9f115ab60a11d9d4f9f0ecf.tar.gz bcm5719-llvm-d28099de5db44eb3f9f115ab60a11d9d4f9f0ecf.zip | |
[libFuzzer] change ValueBitMap to remember the number of bits in it
llvm-svn: 282216
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerValueBitMap.h')
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerValueBitMap.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerValueBitMap.h b/llvm/lib/Fuzzer/FuzzerValueBitMap.h index 07e52fc5a54..fdc92189b47 100644 --- a/llvm/lib/Fuzzer/FuzzerValueBitMap.h +++ b/llvm/lib/Fuzzer/FuzzerValueBitMap.h @@ -38,11 +38,14 @@ struct ValueBitMap { return New != Old; } - // Merges 'Other' into 'this', clears 'Other', - // returns the number of set bits in 'this'. + size_t GetNumBitsSinceLastMerge() const { return NumBits; } + + // Merges 'Other' into 'this', clears 'Other', updates NumBits, + // returns true if new bits were added. ATTRIBUTE_TARGET_POPCNT - size_t MergeFrom(ValueBitMap &Other) { + bool MergeFrom(ValueBitMap &Other) { uintptr_t Res = 0; + size_t OldNumBits = NumBits; for (size_t i = 0; i < kMapSizeInWords; i++) { auto O = Other.Map[i]; auto M = Map[i]; @@ -53,10 +56,12 @@ struct ValueBitMap { if (M) Res += __builtin_popcountl(M); } - return Res; + NumBits = Res; + return OldNumBits < NumBits; } private: + size_t NumBits; uintptr_t Map[kMapSizeInWords] __attribute__((aligned(512))); }; |

