Skip to content

Commit f8b57cd

Browse files
authored
Rollup merge of rust-lang#83655 - sebpop:arm64-outline-atomics, r=workingjubilee
[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
2 parents 175b8db + 0f9f241 commit f8b57cd

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+5
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
416416
// -Ctarget-features
417417
features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter));
418418

419+
// FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12.
420+
if get_version() >= (12, 0, 0) && sess.target.llvm_target.contains("aarch64-unknown-linux") {
421+
features.push("+outline-atomics".to_string());
422+
}
423+
419424
features
420425
}
421426

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+
}

0 commit comments

Comments
 (0)