[libFuzzer] force proper popcnt instruction
authorKostya Serebryany <kcc@google.com>
Wed, 17 Aug 2016 23:09:57 +0000 (23:09 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 17 Aug 2016 23:09:57 +0000 (23:09 +0000)
llvm-svn: 279002

llvm/lib/Fuzzer/FuzzerTraceState.cpp
llvm/lib/Fuzzer/FuzzerValueBitMap.h

index 9eae068c354a422d9cb56eca49507b93d6e877da..963480e2282ed1834384b9cad7a6d5d1930c69f3 100644 (file)
@@ -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));
 }
index 65659f213495c72e23a38c94761ef289e55f7e88..e890e1e903e1f1f44d304d76f3ffe5cf1293ed32 100644 (file)
@@ -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++) {