Skip to content

Commit a32938b

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 39eee17 commit a32938b

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub fn target() -> Target {
88
| SanitizerSet::MEMORY
99
| SanitizerSet::THREAD
1010
| SanitizerSet::HWADDRESS;
11+
base.features = "+outline-atomics".to_string();
1112

1213
Target {
1314
llvm_target: "aarch64-unknown-linux-gnu".to_string(),

compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs

+1
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(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
7+
#![crate_type = "rlib"]
8+
9+
use std::sync::atomic::{AtomicI32, Ordering::*};
10+
11+
pub fn compare_exchange(a: &AtomicI32) {
12+
// On AArch64 LLVM should outline atomic operations.
13+
// CHECK: __aarch64_cas4_relax
14+
let _ = a.compare_exchange(0, 10, Relaxed, Relaxed);
15+
}

0 commit comments

Comments
 (0)