summaryrefslogtreecommitdiffstats
path: root/lib/Fuzzer
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2017-04-21 16:57:37 +0000
committerKuba Mracek <mracek@apple.com>2017-04-21 16:57:37 +0000
commit50c9a25c600f3d6d2f81b7a973fe106994d88745 (patch)
treeb5d88da22daf7dd82fa32176835ef301aa682537 /lib/Fuzzer
parent2602091f822fc2b3d64b1a0c15e1f661e47c7143 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300999 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Fuzzer')
-rw-r--r--lib/Fuzzer/FuzzerDefs.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Fuzzer/FuzzerDefs.h b/lib/Fuzzer/FuzzerDefs.h
index bd1827508002..939b92f55ec4 100644
--- a/lib/Fuzzer/FuzzerDefs.h
+++ b/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