summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/attributes.rs
diff options
context:
space:
mode:
authorKajetan Puchalski <kajetan.puchalski@arm.com>2024-08-09 16:41:43 +0100
committerKajetan Puchalski <kajetan.puchalski@arm.com>2024-08-27 11:13:01 +0100
commit3a0fbb5d4ef32bc74ea388798c3c39db67e62d37 (patch)
treea939476e0920b8e23efec3baf131a8078cf7b2bb /compiler/rustc_codegen_llvm/src/attributes.rs
parent4fc4019cbc6f88350dd0faee1aa658f9508e293e (diff)
downloadrust-3a0fbb5d4ef32bc74ea388798c3c39db67e62d37.tar.gz
rust-3a0fbb5d4ef32bc74ea388798c3c39db67e62d37.zip
rustc_codegen_llvm: Filter out unavailable LLVM features
Convert to_llvm_features to return Option<LLVMFeature> so that it can
return None if the requested feature is not available for the current
LLVM version.

Add match rules to filter out aarch64 features not available in LLVM 17.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/attributes.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/attributes.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs
index 33bdfd3825c..92a857c2adc 100644
--- a/compiler/rustc_codegen_llvm/src/attributes.rs
+++ b/compiler/rustc_codegen_llvm/src/attributes.rs
@@ -521,9 +521,10 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
 
     let function_features = function_features
         .iter()
-        .flat_map(|feat| {
-            llvm_util::to_llvm_features(cx.tcx.sess, feat).into_iter().map(|f| format!("+{f}"))
-        })
+        // Convert to LLVMFeatures and filter out unavailable ones
+        .flat_map(|feat| llvm_util::to_llvm_features(cx.tcx.sess, feat))
+        // Convert LLVMFeatures & dependencies to +<feats>s
+        .flat_map(|feat| feat.into_iter().map(|f| format!("+{f}")))
         .chain(codegen_fn_attrs.instruction_set.iter().map(|x| match x {
             InstructionSetAttr::ArmA32 => "-thumb-mode".to_string(),
             InstructionSetAttr::ArmT32 => "+thumb-mode".to_string(),