Skip to content

Commit 870a132

Browse files
author
Sebastian Pop
committed
[aarch64] add target feature outline-atomics
Enable outline-atomics by default as enabled in clang by the following commit https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11 Performance improves by several orders of magnitude when using the LSE instructions instead of the ARMv8.0 compatible load/store exclusive instructions. Tested on Graviton2 aarch64-linux with x.py build && x.py install && x.py test
1 parent c3c0f80 commit 870a132

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub fn target() -> Target {
99
options: TargetOptions {
1010
mcount: "\u{1}_mcount".to_string(),
1111
max_atomic_width: Some(128),
12+
features: "+outline-atomics".to_string(),
1213
supported_sanitizers: SanitizerSet::ADDRESS
1314
| SanitizerSet::LEAK
1415
| SanitizerSet::MEMORY

compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::spec::{Target, TargetOptions};
33
pub fn target() -> Target {
44
let mut base = super::linux_musl_base::opts();
55
base.max_atomic_width = Some(128);
6+
base.features = "+outline-atomics".to_string();
67

78
Target {
89
llvm_target: "aarch64-unknown-linux-musl".to_string(),
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// min-llvm-version: 12.0
2+
// assembly-output: emit-asm
3+
// compile-flags: -O
4+
// compile-flags: --target aarch64-unknown-linux-gnu
5+
// needs-llvm-components: aarch64
6+
// only-aarch64
7+
8+
#![crate_type = "rlib"]
9+
10+
use std::sync::atomic::{AtomicI32, Ordering::*};
11+
12+
pub fn compare_exchange(a: &AtomicI32) {
13+
// On AArch64 LLVM should outline atomic operations.
14+
// CHECK: __aarch64_cas4_relax
15+
let _ = a.compare_exchange(0, 10, Relaxed, Relaxed);
16+
}

src/test/ui/abi/unsupported.aarch64.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'+outline-atomics' is not a recognized feature for this target (ignoring feature)
12
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
23
--> $DIR/unsupported.rs:26:1
34
|

0 commit comments

Comments
 (0)