rustc_codegen_llvm: make sse4.2 imply crc32 for LLVM 14

This fixes compiling things like the `snap` crate after
https://reviews.llvm.org/D105462. I added a test that verifies the
additional attribute gets specified, and confirmed that I can build
cargo with both LLVM 13 and 14 with this change applied.
This commit is contained in:
Augie Fackler 2021-09-15 10:18:10 -04:00
parent db1fb85cff
commit 4185b76dc3
4 changed files with 83 additions and 34 deletions

View file

@ -305,9 +305,12 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
let mut function_features = codegen_fn_attrs
.target_features
.iter()
.map(|f| {
.flat_map(|f| {
let feature = &f.as_str();
format!("+{}", llvm_util::to_llvm_feature(cx.tcx.sess, feature))
llvm_util::to_llvm_feature(cx.tcx.sess, feature)
.into_iter()
.map(|f| format!("+{}", f))
.collect::<Vec<String>>()
})
.chain(codegen_fn_attrs.instruction_set.iter().map(|x| match x {
InstructionSetAttr::ArmA32 => "-thumb-mode".to_string(),