[llvm] r279002 - [libFuzzer] force proper popcnt instruction
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 16:09:57 PDT 2016
Author: kcc
Date: Wed Aug 17 18:09:57 2016
New Revision: 279002
URL: http://llvm.org/viewvc/llvm-project?rev=279002&view=rev
Log:
[libFuzzer] force proper popcnt instruction
Modified:
llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp
llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h
Modified: llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp?rev=279002&r1=279001&r2=279002&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTraceState.cpp Wed Aug 17 18:09:57 2016
@@ -574,6 +574,7 @@ static void AddValueForStrcmp(void *call
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));
}
Modified: llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h?rev=279002&r1=279001&r2=279002&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerValueBitMap.h Wed Aug 17 18:09:57 2016
@@ -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++) {
More information about the llvm-commits
mailing list