Skip to content

Commit 5a44fff

Browse files
committed
Auto merge of rust-lang#137586 - nnethercote:SetImpliedBits, r=bjorn3
Speed up target feature computation The LLVM backend calls `LLVMRustHasFeature` twice for every feature. In short-running rustc invocations, this accounts for a surprising amount of work. r? `@bjorn3`
2 parents 540565e + 157137a commit 5a44fff

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Diff for: src/lib.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,9 @@ impl CodegenBackend for CraneliftCodegenBackend {
176176
}
177177
}
178178

179-
fn target_features_cfg(
180-
&self,
181-
sess: &Session,
182-
_allow_unstable: bool,
183-
) -> Vec<rustc_span::Symbol> {
179+
fn target_features_cfg(&self, sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
184180
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
185-
if sess.target.arch == "x86_64" && sess.target.os != "none" {
181+
let target_features = if sess.target.arch == "x86_64" && sess.target.os != "none" {
186182
// x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled
187183
vec![sym::fsxr, sym::sse, sym::sse2, Symbol::intern("x87")]
188184
} else if sess.target.arch == "aarch64" {
@@ -196,7 +192,10 @@ impl CodegenBackend for CraneliftCodegenBackend {
196192
}
197193
} else {
198194
vec![]
199-
}
195+
};
196+
// FIXME do `unstable_target_features` properly
197+
let unstable_target_features = target_features.clone();
198+
(target_features, unstable_target_features)
200199
}
201200

202201
fn print_version(&self) {

0 commit comments

Comments
 (0)