Change signature of target_features_cfg
.
Currently it is called twice, once with `allow_unstable` set to true and once with it set to false. This results in some duplicated work. Most notably, for the LLVM backend, `LLVMRustHasFeature` is called twice for every feature, and it's moderately slow. For very short running compilations on platforms with many features (e.g. a `check` build of hello-world on x86) this is a significant fraction of runtime. This commit changes `target_features_cfg` so it is only called once, and it now returns a pair of feature sets. This halves the number of `LLVMRustHasFeature` calls.
This commit is contained in:
parent
2df8e657f2
commit
936a8232df
6 changed files with 85 additions and 71 deletions
|
@ -39,11 +39,11 @@ pub(crate) fn add_configuration(
|
|||
) {
|
||||
let tf = sym::target_feature;
|
||||
|
||||
let unstable_target_features = codegen_backend.target_features_cfg(sess, true);
|
||||
sess.unstable_target_features.extend(unstable_target_features.iter().cloned());
|
||||
let (target_features, unstable_target_features) = codegen_backend.target_features_cfg(sess);
|
||||
|
||||
let target_features = codegen_backend.target_features_cfg(sess, false);
|
||||
sess.target_features.extend(target_features.iter().cloned());
|
||||
sess.unstable_target_features.extend(unstable_target_features.iter().copied());
|
||||
|
||||
sess.target_features.extend(target_features.iter().copied());
|
||||
|
||||
cfg.extend(target_features.into_iter().map(|feat| (tf, Some(feat))));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue