diff options
| author | Kostya Serebryany <kcc@google.com> | 2016-08-17 23:09:57 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2016-08-17 23:09:57 +0000 |
| commit | 5a5d5548f0e69b9dd70285d65c62766958b390b6 (patch) | |
| tree | fbd9826d9df287e13d190fedc5168394904d68d2 | |
| parent | d5ca720209be60a632086d61923d513d6d16c9b5 (diff) | |
| download | bcm5719-llvm-5a5d5548f0e69b9dd70285d65c62766958b390b6.tar.gz bcm5719-llvm-5a5d5548f0e69b9dd70285d65c62766958b390b6.zip | |
[libFuzzer] force proper popcnt instruction
llvm-svn: 279002
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerTraceState.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerValueBitMap.h | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTraceState.cpp b/llvm/lib/Fuzzer/FuzzerTraceState.cpp index 9eae068c354..963480e2282 100644 --- a/llvm/lib/Fuzzer/FuzzerTraceState.cpp +++ b/llvm/lib/Fuzzer/FuzzerTraceState.cpp @@ -574,6 +574,7 @@ static void AddValueForStrcmp(void *caller_pc, const char *s1, const char *s2, VP.AddValue((PC & 4095) | (LastSameByte << 12)); } +__attribute__((target("popcnt"))) static void AddValueForCmp(uintptr_t PC, uint64_t Arg1, uint64_t Arg2) { VP.AddValue((PC & 4095) | (__builtin_popcountl(Arg1 ^ Arg2) << 12)); } diff --git a/llvm/lib/Fuzzer/FuzzerValueBitMap.h b/llvm/lib/Fuzzer/FuzzerValueBitMap.h index 65659f21349..e890e1e903e 100644 --- a/llvm/lib/Fuzzer/FuzzerValueBitMap.h +++ b/llvm/lib/Fuzzer/FuzzerValueBitMap.h @@ -25,7 +25,7 @@ struct ValueBitMap { void Reset() { memset(Map, 0, sizeof(Map)); } // Computed a hash function of Value and sets the corresponding bit. - void AddValue(uintptr_t Value) { + inline void AddValue(uintptr_t Value) { uintptr_t Idx = Value < kMapSizeInBits ? Value : Value % kMapSizeInBits; uintptr_t WordIdx = Idx / kBitsInWord; uintptr_t BitIdx = Idx % kBitsInWord; @@ -34,6 +34,7 @@ struct ValueBitMap { // Merges 'Other' into 'this', clears 'Other', // returns the number of set bits in 'this'. + __attribute__((target("popcnt"))) size_t MergeFrom(ValueBitMap &Other) { uintptr_t Res = 0; for (size_t i = 0; i < kMapSizeInWords; i++) { |

