Skip to content

Commit bceadcf

Browse files
committed
[libFuzzer] use __attribute__((target("popcnt"))) only on x86_64
llvm-svn: 279601
1 parent 79f85b3 commit bceadcf

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

llvm/lib/Fuzzer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}")
22
# Disable the coverage and sanitizer instrumentation for the fuzzer itself.
3-
set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -mpopcnt -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters -Werror")
3+
set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters -Werror")
44
if( LLVM_USE_SANITIZE_COVERAGE )
55
if(NOT "${LLVM_USE_SANITIZER}" STREQUAL "Address")
66
message(FATAL_ERROR

llvm/lib/Fuzzer/FuzzerInternal.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
#include <unordered_set>
2727
#include <vector>
2828

29-
#include "FuzzerExtFunctions.h"
30-
#include "FuzzerInterface.h"
31-
#include "FuzzerValueBitMap.h"
32-
3329
// Platform detection.
3430
#ifdef __linux__
3531
#define LIBFUZZER_LINUX 1
@@ -41,6 +37,16 @@
4137
#error "Support for your platform has not been implemented"
4238
#endif
4339

40+
#ifdef __x86_64
41+
#define ATTRIBUTE_TARGET_POPCNT __attribute__((target("popcnt")))
42+
#else
43+
#define ATTRIBUTE_TARGET_POPCNT
44+
#endif
45+
46+
#include "FuzzerExtFunctions.h"
47+
#include "FuzzerInterface.h"
48+
#include "FuzzerValueBitMap.h"
49+
4450
namespace fuzzer {
4551

4652
typedef int (*UserCallback)(const uint8_t *Data, size_t Size);

llvm/lib/Fuzzer/FuzzerTraceState.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static void AddValueForStrcmp(void *caller_pc, const char *s1, const char *s2,
574574
VP.AddValue((PC & 4095) | (LastSameByte << 12));
575575
}
576576

577-
__attribute__((target("popcnt")))
577+
ATTRIBUTE_TARGET_POPCNT
578578
static void AddValueForCmp(void *PCptr, uint64_t Arg1, uint64_t Arg2) {
579579
if (Arg1 == Arg2)
580580
return;

llvm/lib/Fuzzer/FuzzerValueBitMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct ValueBitMap {
3434

3535
// Merges 'Other' into 'this', clears 'Other',
3636
// returns the number of set bits in 'this'.
37-
__attribute__((target("popcnt")))
37+
ATTRIBUTE_TARGET_POPCNT
3838
size_t MergeFrom(ValueBitMap &Other) {
3939
uintptr_t Res = 0;
4040
for (size_t i = 0; i < kMapSizeInWords; i++) {

0 commit comments

Comments
 (0)