Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aarch64] add target feature outline-atomics #83655

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
// -Ctarget-features
features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter));

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

features
}

Expand Down
16 changes: 16 additions & 0 deletions src/test/assembly/asm/aarch64-outline-atomics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// min-llvm-version: 12.0
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64
// only-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);
}