From 3f8a774b0181a30b066ab92bd4bcde568ff4e4e3 Mon Sep 17 00:00:00 2001 From: Adam Gemmell Date: Thu, 17 Mar 2022 16:32:56 +0000 Subject: [PATCH] Don't error when just giving `neon` as a target feature --- compiler/rustc_codegen_llvm/src/attributes.rs | 2 +- compiler/rustc_codegen_llvm/src/llvm_util.rs | 13 ++++++++++--- src/test/ui/target-feature/tied-features-cli.rs | 4 +++- src/test/ui/target-feature/tied-features.rs | 5 ++++- src/test/ui/target-feature/tied-features.stderr | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 101da0012cb4b..ec21605c39cd8 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -325,7 +325,7 @@ pub fn from_fn_attrs<'ll, 'tcx>( if let Some(f) = llvm_util::check_tied_features( cx.tcx.sess, - &function_features.iter().map(|f| (*f, true)).collect(), + &mut function_features.iter().map(|f| (*f, true)).collect(), ) { let span = cx .tcx diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 3ce594b945ac1..c291c5dd6a028 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -217,8 +217,15 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2] // ensure only valid combinations are allowed. pub fn check_tied_features( sess: &Session, - features: &FxHashMap<&str, bool>, + features: &mut FxHashMap<&str, bool>, ) -> Option<&'static [&'static str]> { + // neon implies fp, so we don't need to error in this case. + if sess.target.arch == "aarch64" && !features.contains_key("fp") { + if let Some(neon) = features.get("neon").copied() { + features.insert("fp", neon); + } + } + for tied in tied_target_features(sess) { // Tied features must be set to the same value, or not set at all let mut tied_iter = tied.iter(); @@ -487,8 +494,8 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec $DIR/tied-features.rs:25:1 + --> $DIR/tied-features.rs:26:1 | LL | #[target_feature(enable = "paca")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^