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
|
@ -45,10 +45,13 @@ pub trait CodegenBackend {
|
|||
|
||||
fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session) {}
|
||||
|
||||
/// Returns the features that should be set in `cfg(target_features)`.
|
||||
/// Returns two feature sets:
|
||||
/// - The first has the features that should be set in `cfg(target_features)`.
|
||||
/// - The second is like the first, but also includes unstable features.
|
||||
///
|
||||
/// RUSTC_SPECIFIC_FEATURES should be skipped here, those are handled outside codegen.
|
||||
fn target_features_cfg(&self, _sess: &Session, _allow_unstable: bool) -> Vec<Symbol> {
|
||||
vec![]
|
||||
fn target_features_cfg(&self, _sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||
(vec![], vec![])
|
||||
}
|
||||
|
||||
fn print_passes(&self) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue