From 382dba52ee0c6142d9a3774d735962797c043fab Mon Sep 17 00:00:00 2001 From: "Tommy Chiang (oToToT)" Date: Tue, 29 Nov 2022 02:48:33 +0800 Subject: [PATCH] v8a as default aarch64 target After https://github.com/llvm/llvm-project/commit/8689f5e landed, LLVM takes the intersection of v8a and v8r as default. This commit brings back v8a support by explicitly specifying v8a in the feature list. This should solve #97724. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 5 +++ src/test/assembly/asm/aarch64-el2vmsa.rs | 37 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/test/assembly/asm/aarch64-el2vmsa.rs diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index bc3a94a4027..dac19b8656d 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -491,6 +491,11 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec= (14, 0, 0) && sess.target.arch == "aarch64" { + features.push("+v8a".into()); + } + if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) { sess.emit_err(TargetFeatureDisableOrEnable { features: f, diff --git a/src/test/assembly/asm/aarch64-el2vmsa.rs b/src/test/assembly/asm/aarch64-el2vmsa.rs new file mode 100644 index 00000000000..1908ffb8ff3 --- /dev/null +++ b/src/test/assembly/asm/aarch64-el2vmsa.rs @@ -0,0 +1,37 @@ +// assembly-output: emit-asm +// compile-flags: --target aarch64-unknown-linux-gnu +// needs-llvm-components: aarch64 + +#![feature(no_core, lang_items, rustc_attrs)] +#![crate_type = "rlib"] +#![no_core] + +#[rustc_builtin_macro] +macro_rules! asm { + () => {}; +} + +#[lang = "sized"] +trait Sized {} + +// CHECK-LABEL: ttbr0_el2: +#[no_mangle] +pub fn ttbr0_el2() { + // CHECK: //APP + // CHECK-NEXT: msr TTBR0_EL2, x0 + // CHECK-NEXT: //NO_APP + unsafe { + asm!("msr ttbr0_el2, x0"); + } +} + +// CHECK-LABEL: vttbr_el2: +#[no_mangle] +pub fn vttbr_el2() { + // CHECK: //APP + // CHECK-NEXT: msr VTTBR_EL2, x0 + // CHECK-NEXT: //NO_APP + unsafe { + asm!("msr vttbr_el2, x0"); + } +}