git: 9f57b84aa13e - stable/13 - Merge commit 16949c5c48ab from llvm-project (by Dimitry Andric):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 23 Jul 2023 18:27:03 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=9f57b84aa13e6a0c8956bdbb9d07eceec4c9bc21

commit 9f57b84aa13e6a0c8956bdbb9d07eceec4c9bc21
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-04-20 19:21:37 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-07-23 17:38:09 +0000

    Merge commit 16949c5c48ab from llvm-project (by Dimitry Andric):
    
      [compiler-rt] Include system headers before optionally defining HWCAP macros
    
      In https://reviews.llvm.org/D141285 the optional definitions of `HWCAP`
      macros were moved to before their usage. However, they were also moved
      to before the inclusion of system headers which can optionally define
      them. If any of those system headers then actually defined any of the
      `HWCAP` macros, it would result in a redefinition error.
    
      Move the system header includes to just before the optional definitions,
      to avoid this problem.
    
      Reviewed By: ilinpv
    
      Differential Revision: https://reviews.llvm.org/D148819
    
    PR:             271047
    MFC after:      1 month
    
    (cherry picked from commit 482e0fcdf745981f2c2b12311405fe93563cefc4)
---
 .../compiler-rt/lib/builtins/cpu_model.c           | 38 +++++++++++-----------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c b/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c
index f5ad530c7e88..f2dcd974008c 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c
@@ -839,6 +839,25 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
 }
 #elif defined(__aarch64__)
 
+// LSE support detection for out-of-line atomics
+// using HWCAP and Auxiliary vector
+_Bool __aarch64_have_lse_atomics
+    __attribute__((visibility("hidden"), nocommon));
+
+#if defined(__has_include)
+#if __has_include(<sys/auxv.h>)
+#include <sys/auxv.h>
+#if __has_include(<asm/hwcap.h>)
+#include <asm/hwcap.h>
+
+#if defined(__ANDROID__)
+#include <string.h>
+#include <sys/system_properties.h>
+#elif defined(__Fuchsia__)
+#include <zircon/features.h>
+#include <zircon/syscalls.h>
+#endif
+
 #ifndef AT_HWCAP
 #define AT_HWCAP 16
 #endif
@@ -1009,25 +1028,6 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
 #define HWCAP2_SVE_EBF16 (1UL << 33)
 #endif
 
-// LSE support detection for out-of-line atomics
-// using HWCAP and Auxiliary vector
-_Bool __aarch64_have_lse_atomics
-    __attribute__((visibility("hidden"), nocommon));
-
-#if defined(__has_include)
-#if __has_include(<sys/auxv.h>)
-#include <sys/auxv.h>
-#if __has_include(<asm/hwcap.h>)
-#include <asm/hwcap.h>
-
-#if defined(__ANDROID__)
-#include <string.h>
-#include <sys/system_properties.h>
-#elif defined(__Fuchsia__)
-#include <zircon/features.h>
-#include <zircon/syscalls.h>
-#endif
-
 // Detect Exynos 9810 CPU
 #define IF_EXYNOS9810                                                          \
   char arch[PROP_VALUE_MAX];                                                   \