Skip to content

Commit 21bda22

Browse files
authored
Rollup merge of #144938 - tgross35:more-outline-atomics, r=davidtwco
Enable `outline-atomics` by default on more AArch64 platforms The baseline Armv8.0 ISA doesn't have atomics instructions, but in practice most hardware is at least Armv8.1-A (2014), which includes single-instruction atomics as part of the LSE feature. As a performance optimization for these cases, GCC and LLVM have the `-moutline-atomics` flag to turn atomic operations into calls to symbols like `__aarch64_cas1_acq`. These can do runtime feature detection and use the LSE instructions if available, falling back to more portable load-exclusive/store-exclusive loops. Since the recent 3b50253b57b1 ("compiler-builtins: plumb LSE support for aarch64 on linux") our builtins support this LSE optimization, and since 6936bb975a50 ("Dynamically enable LSE for aarch64 rust provided intrinsics"), std will set the flag as part of its startup code. The first commit in this PR configures this to work on all platforms built with `outline-atomics`, not just Linux. Thus, enable `outline-atomics` by default on Android, OpenBSD, Windows, and Fuchsia platforms that don't have LSE in the baseline. The feature is already enabled on Linux. Platform-specific details are included in each commit message. The current implementation can still be accessed by setting `-Ctarget-feature=-outline-atomics`. Setting `-Ctarget-feature=+lse` or a relevant CPU will use the single-instruction atomics without the call overhead. https://rust.godbolt.org/z/dsdrzszoe Link: https://learn.arm.com/learning-paths/servers-and-cloud-computing/lse/intro/ Original Clang outline-atomics benchmarks: https://reviews.llvm.org/D91157#2435844 try-job: aarch64-msvc-* try-job: arm-android try-job: dist-android try-job: dist-aarch64-llvm-mingw try-job: dist-aarch64-msvc try-job: dist-various-* try-job: test-various
2 parents bfd7aca + e50678a commit 21bda22

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler-builtins/src/aarch64_linux.rs renamed to compiler-builtins/src/aarch64_outline_atomics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ macro_rules! compare_and_swap {
196196
"cbnz w17, 0b",
197197
"1:",
198198
"ret",
199-
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
199+
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
200200
}
201201
}
202202
}
@@ -228,7 +228,7 @@ macro_rules! compare_and_swap_i128 {
228228
"cbnz w15, 0b",
229229
"1:",
230230
"ret",
231-
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
231+
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
232232
}
233233
}
234234
}
@@ -256,7 +256,7 @@ macro_rules! swap {
256256
concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 16), ", [x1]"),
257257
"cbnz w17, 0b",
258258
"ret",
259-
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
259+
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
260260
}
261261
}
262262
}
@@ -286,7 +286,7 @@ macro_rules! fetch_op {
286286
concat!(stxr!($ordering, $bytes), " w15, ", reg!($bytes, 17), ", [x1]"),
287287
"cbnz w15, 0b",
288288
"ret",
289-
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
289+
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
290290
}
291291
}
292292
}

compiler-builtins/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub mod arm;
5555
#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
5656
pub mod aarch64;
5757

58-
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
59-
pub mod aarch64_linux;
58+
#[cfg(all(target_arch = "aarch64", target_feature = "outline-atomics"))]
59+
pub mod aarch64_outline_atomics;
6060

6161
#[cfg(all(
6262
kernel_user_helpers,

0 commit comments

Comments
 (0)