Skip to content

builtins: adjust code for ARM64 on MSVC harder #9301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2024
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
1 change: 1 addition & 0 deletions compiler-rt/lib/builtins/aarch64/fp_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// For soft float targets, allow changing rounding mode by overriding the weak
// __aarch64_fe_default_rmode symbol.
#if defined(_MSC_VER)
extern CRT_FE_ROUND_MODE __default_rmode;
CRT_FE_ROUND_MODE __default_rmode = CRT_FE_TONEAREST;
#pragma comment(linker, "/alternatename:__aarch64_fe_default_rmode=__default_rmode")
#else
Expand Down
15 changes: 3 additions & 12 deletions compiler-rt/lib/builtins/aarch64/lse.S
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
.arch armv8-a
#endif

#if !defined(__APPLE__)
HIDDEN(__aarch64_have_lse_atomics)
#else
HIDDEN(___aarch64_have_lse_atomics)
#endif
HIDDEN(SYMBOL_NAME(__aarch64_have_lse_atomics))

// Generate mnemonics for
// L_cas: SIZE: 1,2,4,8,16 MODEL: 1,2,3,4,5
Expand Down Expand Up @@ -131,13 +127,8 @@ HIDDEN(___aarch64_have_lse_atomics)

// Macro for branch to label if no LSE available
.macro JUMP_IF_NOT_LSE label
#if !defined(__APPLE__)
adrp x(tmp0), __aarch64_have_lse_atomics
ldrb w(tmp0), [x(tmp0), :lo12:__aarch64_have_lse_atomics]
#else
adrp x(tmp0), ___aarch64_have_lse_atomics@page
ldrb w(tmp0), [x(tmp0), ___aarch64_have_lse_atomics@pageoff]
#endif
adrp x(tmp0), SYMBOL_NAME(__aarch64_have_lse_atomics)
ldrb w(tmp0), [x(tmp0), :lo12:SYMBOL_NAME(__aarch64_have_lse_atomics)]
cbz w(tmp0), \label
.endm

Expand Down
20 changes: 15 additions & 5 deletions compiler-rt/lib/builtins/cpu_model/aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ typedef struct __ifunc_arg_t {

// LSE support detection for out-of-line atomics
// using HWCAP and Auxiliary vector
_Bool __aarch64_have_lse_atomics
__attribute__((visibility("hidden"), nocommon)) = false;
#if defined(_MSC_VER)
__declspec(allocate(".data"))
#else
__attribute__((__visibility__("hidden"), __nocommon__))
#endif
_Bool __aarch64_have_lse_atomics = false;

#if defined(__FreeBSD__)
// clang-format off: should not reorder sys/auxv.h alphabetically
Expand All @@ -54,12 +58,18 @@ _Bool __aarch64_have_lse_atomics

#if !defined(DISABLE_AARCH64_FMV)

// Architecture features used
// in Function Multi Versioning
// Architecture features used in function multi-versioning
#if defined(_MSC_VER)
__declspec(allocate(".data"))
#endif
struct {
unsigned long long features;
// As features grows new fields could be added
} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon));
} __aarch64_cpu_features
#if !defined(_MSC_VER)
__attribute__((__visibility__("hidden"), __nocommon__))
#endif
;

// The formatter wants to re-order these includes, but doing so is incorrect:
// clang-format off
Expand Down