Add implied features to non-target-feature functions
This commit is contained in:
parent
5006711744
commit
6b96a60611
@ -8,6 +8,7 @@
|
|||||||
use rustc_codegen_ssa::base::wants_wasm_eh;
|
use rustc_codegen_ssa::base::wants_wasm_eh;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::small_c_str::SmallCStr;
|
use rustc_data_structures::small_c_str::SmallCStr;
|
||||||
|
use rustc_data_structures::unord::UnordSet;
|
||||||
use rustc_fs_util::path_to_c_string;
|
use rustc_fs_util::path_to_c_string;
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_session::config::{PrintKind, PrintRequest};
|
use rustc_session::config::{PrintKind, PrintRequest};
|
||||||
@ -553,11 +554,26 @@ pub(crate) fn global_llvm_features(
|
|||||||
let supported_features = sess.target.supported_target_features();
|
let supported_features = sess.target.supported_target_features();
|
||||||
let (llvm_major, _, _) = get_version();
|
let (llvm_major, _, _) = get_version();
|
||||||
let mut featsmap = FxHashMap::default();
|
let mut featsmap = FxHashMap::default();
|
||||||
let feats = sess
|
|
||||||
.opts
|
// insert implied features
|
||||||
.cg
|
let mut all_rust_features = vec![];
|
||||||
.target_feature
|
for feature in sess.opts.cg.target_feature.split(',') {
|
||||||
.split(',')
|
match feature.strip_prefix('+') {
|
||||||
|
Some(feature) => all_rust_features.extend(
|
||||||
|
UnordSet::from(
|
||||||
|
sess.target
|
||||||
|
.implied_target_features(std::iter::once(Symbol::intern(feature))),
|
||||||
|
)
|
||||||
|
.to_sorted_stable_ord()
|
||||||
|
.iter()
|
||||||
|
.map(|s| format!("+{}", s.as_str())),
|
||||||
|
),
|
||||||
|
_ => all_rust_features.push(feature.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let feats = all_rust_features
|
||||||
|
.iter()
|
||||||
.filter_map(|s| {
|
.filter_map(|s| {
|
||||||
let enable_disable = match s.chars().next() {
|
let enable_disable = match s.chars().next() {
|
||||||
None => return None,
|
None => return None,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//@ revisions: COMPAT INCOMPAT
|
//@ revisions: COMPAT INCOMPAT
|
||||||
//@ needs-llvm-components: x86
|
//@ needs-llvm-components: x86
|
||||||
//@ compile-flags: --target=x86_64-unknown-linux-gnu -Copt-level=3
|
//@ compile-flags: --target=x86_64-unknown-linux-gnu -Copt-level=3
|
||||||
//@ [COMPAT] compile-flags: -Ctarget-feature=+avx2,+avx
|
//@ [COMPAT] compile-flags: -Ctarget-feature=+avx2
|
||||||
//@ [INCOMPAT] compile-flags: -Ctarget-feature=-avx2,-avx
|
//@ [INCOMPAT] compile-flags: -Ctarget-feature=-avx2,-avx
|
||||||
|
|
||||||
// See also tests/assembly/target-feature-multiple.rs
|
// See also tests/assembly/target-feature-multiple.rs
|
||||||
@ -39,8 +39,8 @@ pub unsafe fn banana() -> u32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CHECK: attributes [[APPLEATTRS]]
|
// CHECK: attributes [[APPLEATTRS]]
|
||||||
// COMPAT-SAME: "target-features"="+avx2,+avx,{{.*}}"
|
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
|
||||||
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+avx,{{.*}}"
|
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+avx,{{.*}}"
|
||||||
// CHECK: attributes [[BANANAATTRS]]
|
// CHECK: attributes [[BANANAATTRS]]
|
||||||
// COMPAT-SAME: "target-features"="+avx2,+avx,{{.*}}"
|
// COMPAT-SAME: "target-features"="+avx,+avx2,{{.*}}"
|
||||||
// INCOMPAT-SAME: "target-features"="-avx2,-avx"
|
// INCOMPAT-SAME: "target-features"="-avx2,-avx"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
// is LLVM-14 we can remove the optional regex matching for this feature.
|
// is LLVM-14 we can remove the optional regex matching for this feature.
|
||||||
|
|
||||||
//@ [ENABLE_SVE] compile-flags: -C target-feature=+sve -Copt-level=0
|
//@ [ENABLE_SVE] compile-flags: -C target-feature=+sve -Copt-level=0
|
||||||
// ENABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+sve,?)|(\+neon,?))*}}" }
|
// ENABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+sve,?)|(\+neon,?)|(\+fp-armv8,?))*}}" }
|
||||||
|
|
||||||
//@ [DISABLE_SVE] compile-flags: -C target-feature=-sve -Copt-level=0
|
//@ [DISABLE_SVE] compile-flags: -C target-feature=-sve -Copt-level=0
|
||||||
// DISABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-sve,?)|(\+neon,?))*}}" }
|
// DISABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-sve,?)|(\+neon,?))*}}" }
|
||||||
|
Loading…
Reference in New Issue
Block a user