Author: Michael Spencer Date: 2020-03-06T13:48:09-08:00 New Revision: 16af23fae8ad2949048e0fc34cf9114dfbe4742a
URL: https://github.com/llvm/llvm-project/commit/16af23fae8ad2949048e0fc34cf9114dfbe4742a DIFF: https://github.com/llvm/llvm-project/commit/16af23fae8ad2949048e0fc34cf9114dfbe4742a.diff LOG: [clang][Headers] Use __has_builtin instead of _MSC_VER. arm_acle.h relied on `_MSC_VER` to determine if a given function was already defined as a builtin. This was incorrect because `-fms-extensions` enables these builtins, but is not responsible for defining `_MSC_VER` on any target. The next closest thing is `_MSC_EXTENSIONS`, which is only defined on Windows targets, but even this is suboptimal. What this conditional is actually trying to determine is if the given functions are defined as builtins, so just check that directly. I also attempted to do this for `__nop`, but in that case intrin.h, which is only includable if `_MSC_VER` is defined, has its own definition. So in that case `_MSC_VER` is correct. Differential Revision: https://reviews.llvm.org/D75719 rdar://60102353 Added: Modified: clang/lib/Headers/arm_acle.h clang/test/Headers/arm-acle-header.c Removed: ################################################################################ diff --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h index 596ea03cff2f..de568b4ff9c5 100644 --- a/clang/lib/Headers/arm_acle.h +++ b/clang/lib/Headers/arm_acle.h @@ -22,31 +22,43 @@ extern "C" { /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */ /* 8.3 Memory barriers */ -#if !defined(_MSC_VER) +#if !__has_builtin(__dmb) #define __dmb(i) __builtin_arm_dmb(i) +#endif +#if !__has_builtin(__dsb) #define __dsb(i) __builtin_arm_dsb(i) +#endif +#if !__has_builtin(__isb) #define __isb(i) __builtin_arm_isb(i) #endif /* 8.4 Hints */ -#if !defined(_MSC_VER) +#if !__has_builtin(__wfi) static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfi(void) { __builtin_arm_wfi(); } +#endif +#if !__has_builtin(__wfe) static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfe(void) { __builtin_arm_wfe(); } +#endif +#if !__has_builtin(__sev) static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sev(void) { __builtin_arm_sev(); } +#endif +#if !__has_builtin(__sevl) static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sevl(void) { __builtin_arm_sevl(); } +#endif +#if !__has_builtin(__yield) static __inline__ void __attribute__((__always_inline__, __nodebug__)) __yield(void) { __builtin_arm_yield(); } diff --git a/clang/test/Headers/arm-acle-header.c b/clang/test/Headers/arm-acle-header.c index 932c59da3d96..e50a68c64b0f 100644 --- a/clang/test/Headers/arm-acle-header.c +++ b/clang/test/Headers/arm-acle-header.c @@ -6,6 +6,7 @@ // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 -fsyntax-only -ffreestanding %s // RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 -fsyntax-only -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=19.11 %s // RUN: %clang_cc1 -x c++ -triple aarch64-windows -target-cpu cortex-a53 -fsyntax-only -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=19.11 %s +// RUN: %clang_cc1 -x c++ -triple arm64-apple-ios -target-cpu apple-a7 -fsyntax-only -ffreestanding -fms-extensions %s // expected-no-diagnostics #include <arm_acle.h> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits