From bceadcf1cd8f8128c92b1b2f3d4a11ba85f480cb Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Wed, 24 Aug 2016 01:38:42 +0000 Subject: [PATCH] [libFuzzer] use __attribute__((target("popcnt"))) only on x86_64 llvm-svn: 279601 --- llvm/lib/Fuzzer/CMakeLists.txt | 2 +- llvm/lib/Fuzzer/FuzzerInternal.h | 14 ++++++++++---- llvm/lib/Fuzzer/FuzzerTraceState.cpp | 2 +- llvm/lib/Fuzzer/FuzzerValueBitMap.h | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Fuzzer/CMakeLists.txt b/llvm/lib/Fuzzer/CMakeLists.txt index 05e058163656..1829f0586b85 100644 --- a/llvm/lib/Fuzzer/CMakeLists.txt +++ b/llvm/lib/Fuzzer/CMakeLists.txt @@ -1,6 +1,6 @@ set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}") # Disable the coverage and sanitizer instrumentation for the fuzzer itself. -set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -mpopcnt -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters -Werror") +set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters -Werror") if( LLVM_USE_SANITIZE_COVERAGE ) if(NOT "${LLVM_USE_SANITIZER}" STREQUAL "Address") message(FATAL_ERROR diff --git a/llvm/lib/Fuzzer/FuzzerInternal.h b/llvm/lib/Fuzzer/FuzzerInternal.h index 0212f94fa3b3..c7382c9cd6ce 100644 --- a/llvm/lib/Fuzzer/FuzzerInternal.h +++ b/llvm/lib/Fuzzer/FuzzerInternal.h @@ -26,10 +26,6 @@ #include #include -#include "FuzzerExtFunctions.h" -#include "FuzzerInterface.h" -#include "FuzzerValueBitMap.h" - // Platform detection. #ifdef __linux__ #define LIBFUZZER_LINUX 1 @@ -41,6 +37,16 @@ #error "Support for your platform has not been implemented" #endif +#ifdef __x86_64 +#define ATTRIBUTE_TARGET_POPCNT __attribute__((target("popcnt"))) +#else +#define ATTRIBUTE_TARGET_POPCNT +#endif + +#include "FuzzerExtFunctions.h" +#include "FuzzerInterface.h" +#include "FuzzerValueBitMap.h" + namespace fuzzer { typedef int (*UserCallback)(const uint8_t *Data, size_t Size); diff --git a/llvm/lib/Fuzzer/FuzzerTraceState.cpp b/llvm/lib/Fuzzer/FuzzerTraceState.cpp index 4192ceb7e92e..f1307d7d3a2d 100644 --- a/llvm/lib/Fuzzer/FuzzerTraceState.cpp +++ b/llvm/lib/Fuzzer/FuzzerTraceState.cpp @@ -574,7 +574,7 @@ static void AddValueForStrcmp(void *caller_pc, const char *s1, const char *s2, VP.AddValue((PC & 4095) | (LastSameByte << 12)); } -__attribute__((target("popcnt"))) +ATTRIBUTE_TARGET_POPCNT static void AddValueForCmp(void *PCptr, uint64_t Arg1, uint64_t Arg2) { if (Arg1 == Arg2) return; diff --git a/llvm/lib/Fuzzer/FuzzerValueBitMap.h b/llvm/lib/Fuzzer/FuzzerValueBitMap.h index e890e1e903e1..2a917333e21d 100644 --- a/llvm/lib/Fuzzer/FuzzerValueBitMap.h +++ b/llvm/lib/Fuzzer/FuzzerValueBitMap.h @@ -34,7 +34,7 @@ struct ValueBitMap { // Merges 'Other' into 'this', clears 'Other', // returns the number of set bits in 'this'. - __attribute__((target("popcnt"))) + ATTRIBUTE_TARGET_POPCNT size_t MergeFrom(ValueBitMap &Other) { uintptr_t Res = 0; for (size_t i = 0; i < kMapSizeInWords; i++) {