rustc/driver: improve/remove allocations
This commit is contained in:
parent
39753c8973
commit
9a1de086e4
@ -1586,9 +1586,8 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
|
||||
base.dedup();
|
||||
}
|
||||
|
||||
base.into_iter()
|
||||
.filter(|crate_type| {
|
||||
let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type);
|
||||
base.retain(|crate_type| {
|
||||
let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type);
|
||||
|
||||
if !res {
|
||||
session.warn(&format!(
|
||||
@ -1597,9 +1596,10 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
|
||||
));
|
||||
}
|
||||
|
||||
res
|
||||
})
|
||||
.collect()
|
||||
res
|
||||
});
|
||||
|
||||
base
|
||||
}
|
||||
|
||||
pub fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator {
|
||||
|
@ -137,9 +137,7 @@ pub mod target_features {
|
||||
codegen_backend: &dyn CodegenBackend) {
|
||||
let tf = Symbol::intern("target_feature");
|
||||
|
||||
for feat in codegen_backend.target_features(sess) {
|
||||
cfg.insert((tf, Some(feat)));
|
||||
}
|
||||
cfg.extend(codegen_backend.target_features(sess).into_iter().map(|feat| (tf, Some(feat))));
|
||||
|
||||
if sess.crt_static_feature() {
|
||||
cfg.insert((tf, Some(Symbol::intern("crt-static"))));
|
||||
@ -997,7 +995,7 @@ impl RustcDefaultCalls {
|
||||
input: &Input)
|
||||
-> Compilation {
|
||||
let r = matches.opt_strs("Z");
|
||||
if r.contains(&("ls".to_string())) {
|
||||
if r.iter().any(|s| *s == "ls") {
|
||||
match input {
|
||||
&Input::File(ref ifile) => {
|
||||
let path = &(*ifile);
|
||||
@ -1085,8 +1083,7 @@ impl RustcDefaultCalls {
|
||||
let allow_unstable_cfg = UnstableFeatures::from_environment()
|
||||
.is_nightly_build();
|
||||
|
||||
let mut cfgs = Vec::new();
|
||||
for &(name, ref value) in sess.parse_sess.config.iter() {
|
||||
let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| {
|
||||
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
|
||||
ident: ast::Path::from_ident(ast::Ident::with_empty_ctxt(name)),
|
||||
node: ast::MetaItemKind::Word,
|
||||
@ -1105,16 +1102,16 @@ impl RustcDefaultCalls {
|
||||
let value = value.as_ref().map(|s| s.as_ref());
|
||||
if name != "target_feature" || value != Some("crt-static") {
|
||||
if !allow_unstable_cfg && gated_cfg.is_some() {
|
||||
continue;
|
||||
return None
|
||||
}
|
||||
}
|
||||
|
||||
cfgs.push(if let Some(value) = value {
|
||||
format!("{}=\"{}\"", name, value)
|
||||
if let Some(value) = value {
|
||||
Some(format!("{}=\"{}\"", name, value))
|
||||
} else {
|
||||
name.to_string()
|
||||
});
|
||||
}
|
||||
Some(name.to_string())
|
||||
}
|
||||
}).collect::<Vec<String>>();
|
||||
|
||||
cfgs.sort();
|
||||
for cfg in cfgs {
|
||||
@ -1177,7 +1174,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
|
||||
for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
|
||||
(option.apply)(&mut options);
|
||||
}
|
||||
let message = "Usage: rustc [OPTIONS] INPUT".to_string();
|
||||
let message = "Usage: rustc [OPTIONS] INPUT";
|
||||
let nightly_help = if nightly_options::is_nightly_build() {
|
||||
"\n -Z help Print internal options for debugging rustc"
|
||||
} else {
|
||||
@ -1192,7 +1189,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
|
||||
-C help Print codegen options
|
||||
-W help \
|
||||
Print 'lint' options and default settings{}{}\n",
|
||||
options.usage(&message),
|
||||
options.usage(message),
|
||||
nightly_help,
|
||||
verbose_help);
|
||||
}
|
||||
@ -1463,7 +1460,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
|
||||
"the --no-stack-check flag is deprecated and does nothing");
|
||||
}
|
||||
|
||||
if cg_flags.contains(&"passes=list".to_string()) {
|
||||
if cg_flags.iter().any(|x| *x == "passes=list") {
|
||||
get_codegen_sysroot("llvm")().print_passes();
|
||||
return None;
|
||||
}
|
||||
|
@ -89,18 +89,18 @@ fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) {
|
||||
)
|
||||
}
|
||||
|
||||
fn html_of_fraction(frac: f64) -> (String, String) {
|
||||
fn html_of_fraction(frac: f64) -> (String, &'static str) {
|
||||
let css = {
|
||||
if frac > 0.50 { "frac-50".to_string() }
|
||||
else if frac > 0.40 { "frac-40".to_string() }
|
||||
else if frac > 0.30 { "frac-30".to_string() }
|
||||
else if frac > 0.20 { "frac-20".to_string() }
|
||||
else if frac > 0.10 { "frac-10".to_string() }
|
||||
else if frac > 0.05 { "frac-05".to_string() }
|
||||
else if frac > 0.02 { "frac-02".to_string() }
|
||||
else if frac > 0.01 { "frac-01".to_string() }
|
||||
else if frac > 0.001 { "frac-001".to_string() }
|
||||
else { "frac-0".to_string() }
|
||||
if frac > 0.50 { "frac-50" }
|
||||
else if frac > 0.40 { "frac-40" }
|
||||
else if frac > 0.30 { "frac-30" }
|
||||
else if frac > 0.20 { "frac-20" }
|
||||
else if frac > 0.10 { "frac-10" }
|
||||
else if frac > 0.05 { "frac-05" }
|
||||
else if frac > 0.02 { "frac-02" }
|
||||
else if frac > 0.01 { "frac-01" }
|
||||
else if frac > 0.001 { "frac-001" }
|
||||
else { "frac-0" }
|
||||
};
|
||||
let percent = frac * 100.0;
|
||||
if percent > 0.1 { (format!("{:.1}%", percent), css) }
|
||||
@ -148,6 +148,7 @@ fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usi
|
||||
}
|
||||
|
||||
fn compute_counts_rec(counts: &mut FxHashMap<String,QueryMetric>, traces: &[Rec]) {
|
||||
counts.reserve(traces.len());
|
||||
for t in traces.iter() {
|
||||
match t.effect {
|
||||
Effect::TimeBegin(ref msg) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user