Skip to content

Commit

Permalink
[aarch64] add target feature outline-atomics
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sebastian Pop committed Apr 30, 2021
1 parent 39eee17 commit a32938b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub fn target() -> Target {
| SanitizerSet::MEMORY
| SanitizerSet::THREAD
| SanitizerSet::HWADDRESS;
base.features = "+outline-atomics".to_string();

Target {
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.max_atomic_width = Some(128);
base.features = "+outline-atomics".to_string();

Target {
llvm_target: "aarch64-unknown-linux-musl".to_string(),
Expand Down
15 changes: 15 additions & 0 deletions src/test/assembly/asm/aarch64-outline-atomics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// min-llvm-version: 12.0
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64

#![crate_type = "rlib"]

use std::sync::atomic::{AtomicI32, Ordering::*};

pub fn compare_exchange(a: &AtomicI32) {
// On AArch64 LLVM should outline atomic operations.
// CHECK: __aarch64_cas4_relax
let _ = a.compare_exchange(0, 10, Relaxed, Relaxed);
}

0 comments on commit a32938b

Please sign in to comment.