Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions compiler-rt/lib/builtins/cpu_model/aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
#error This file is intended only for aarch64-based targets
#endif

#if __has_include(<sys/ifunc.h>)
#include <sys/ifunc.h>
#else
typedef struct __ifunc_arg_t {
unsigned long _size;
unsigned long _hwcap;
unsigned long _hwcap2;
unsigned long _hwcap3;
unsigned long _hwcap4;
} __ifunc_arg_t;
#endif // __has_include(<sys/ifunc.h>)

// LSE support detection for out-of-line atomics
// using HWCAP and Auxiliary vector
Expand Down
9 changes: 4 additions & 5 deletions compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void) {
if (__isExynos9810())
return;

unsigned long hwcap = getauxval(AT_HWCAP);
unsigned long hwcap2 = getauxval(AT_HWCAP2);

__ifunc_arg_t arg;
arg._size = sizeof(__ifunc_arg_t);
arg._hwcap = hwcap;
arg._hwcap2 = hwcap2;
arg._hwcap = getauxval(AT_HWCAP);
arg._hwcap2 = getauxval(AT_HWCAP2);
arg._hwcap3 = getauxval(AT_HWCAP3);
arg._hwcap4 = getauxval(AT_HWCAP4);
__init_cpu_features_constructor(hwcap | _IFUNC_ARG_HWCAP, &arg);
Copy link
Member

@petrhosek petrhosek Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is still referencing hwcap but the variable is no longer defined anywhere.

}
14 changes: 7 additions & 7 deletions compiler-rt/lib/builtins/cpu_model/aarch64/fmv/elf_aux_info.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ void __init_cpu_features_resolver(unsigned long hwcap,
}

void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void) {
unsigned long hwcap = 0;
unsigned long hwcap2 = 0;
unsigned long hwcap, hwcap2, hwcap3, hwcap4 = 0;
// CPU features already initialized.
if (__atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED))
return;

int res = 0;
res = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
res |= elf_aux_info(AT_HWCAP2, &hwcap2, sizeof hwcap2);
if (res)
return;
elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
elf_aux_info(AT_HWCAP2, &hwcap2, sizeof hwcap2);
elf_aux_info(AT_HWCAP3, &hwcap3, sizeof hwcap3);
elf_aux_info(AT_HWCAP4, &hwcap4, sizeof hwcap4);

__ifunc_arg_t arg;
arg._size = sizeof(__ifunc_arg_t);
arg._hwcap = hwcap;
arg._hwcap2 = hwcap2;
arg._hwcap3 = hwcap3;
arg._hwcap4 = hwcap4;
__init_cpu_features_constructor(hwcap | _IFUNC_ARG_HWCAP, &arg);
}
9 changes: 4 additions & 5 deletions compiler-rt/lib/builtins/cpu_model/aarch64/fmv/getauxval.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void) {
if (__atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED))
return;

unsigned long hwcap = getauxval(AT_HWCAP);
unsigned long hwcap2 = getauxval(AT_HWCAP2);

__ifunc_arg_t arg;
arg._size = sizeof(__ifunc_arg_t);
arg._hwcap = hwcap;
arg._hwcap2 = hwcap2;
arg._hwcap = getauxval(AT_HWCAP);
arg._hwcap2 = getauxval(AT_HWCAP2);
arg._hwcap3 = getauxval(AT_HWCAP3);
arg._hwcap4 = getauxval(AT_HWCAP4);
__init_cpu_features_constructor(hwcap | _IFUNC_ARG_HWCAP, &arg);
}
20 changes: 18 additions & 2 deletions compiler-rt/lib/builtins/cpu_model/aarch64/hwcap.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define _IFUNC_ARG_HWCAP (1ULL << 62)
#endif
#ifndef AT_HWCAP
#define AT_HWCAP 16
#define AT_HWCAP 16 // Linux value
#endif
#ifndef HWCAP_CPUID
#define HWCAP_CPUID (1 << 11)
Expand Down Expand Up @@ -95,7 +95,7 @@
#endif

#ifndef AT_HWCAP2
#define AT_HWCAP2 26
#define AT_HWCAP2 26 // Linux value
#endif
#ifndef HWCAP2_DCPODP
#define HWCAP2_DCPODP (1 << 0)
Expand Down Expand Up @@ -190,3 +190,19 @@
#ifndef HWCAP2_CSSC
#define HWCAP2_CSSC (1UL << 34)
#endif

#ifndef AT_HWCAP3
#ifdef __linux__
#define AT_HWCAP3 29 // Linux value
#else
#define AT_HWCAP3 38 // BSD value
#endif
#endif

#ifndef AT_HWCAP4
#ifdef __linux__
#define AT_HWCAP4 30 // Linux value
#else
#define AT_HWCAP4 39 // BSD value
#endif
#endif