diff options
author | Kuba Mracek <mracek@apple.com> | 2017-04-21 16:57:37 +0000 |
---|---|---|
committer | Kuba Mracek <mracek@apple.com> | 2017-04-21 16:57:37 +0000 |
commit | 9eb170fede34b4cf3ee43998e4e0f04240b72b3b (patch) | |
tree | 426e953f123755f2e79e96e1dfafb8f789b5e1d0 /llvm | |
parent | 894da663203c2cb28a54cb0b6ffdf380792e6057 (diff) | |
download | bcm5719-llvm-9eb170fede34b4cf3ee43998e4e0f04240b72b3b.tar.gz bcm5719-llvm-9eb170fede34b4cf3ee43998e4e0f04240b72b3b.zip |
[libFuzzer] Check for target(popcnt) capability before usage
Older compilers (e.g. LLVM 3.4) do not support the attribute target("popcnt").
In order to support those, this diff check the attribute support using the preprocessor.
Patch by George Karpenkov.
Differential Revision: https://reviews.llvm.org/D32311
llvm-svn: 300999
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerDefs.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerDefs.h b/llvm/lib/Fuzzer/FuzzerDefs.h index bd182750800..939b92f55ec 100644 --- a/llvm/lib/Fuzzer/FuzzerDefs.h +++ b/llvm/lib/Fuzzer/FuzzerDefs.h @@ -36,12 +36,20 @@ #error "Support for your platform has not been implemented" #endif +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + #define LIBFUZZER_POSIX LIBFUZZER_APPLE || LIBFUZZER_LINUX #ifdef __x86_64 -#define ATTRIBUTE_TARGET_POPCNT __attribute__((target("popcnt"))) +# if __has_attribute(target) +# define ATTRIBUTE_TARGET_POPCNT __attribute__((target("popcnt"))) +# else +# define ATTRIBUTE_TARGET_POPCNT +# endif #else -#define ATTRIBUTE_TARGET_POPCNT +# define ATTRIBUTE_TARGET_POPCNT #endif |