Hi all,
While reading the rustc 1.90 source, I noticed that mir-opt-level is defined as:
pub fn mir_opt_level(&self) -> usize {
self.opts.unstable_opts.mir_opt_level
.unwrap_or_else(|| if self.opts.optimize != OptLevel::No { 2 } else { 1 })
}
and in rustc_mir_transform/src/lib.rs,all passes are registered as:
WithMinOptLevel(1, x)
and within rustc_mir_transform/src/lib.rs, the optimization passes are organized roughly as:
fn o1<T>(x: T) -> WithMinOptLevel<T> {
WithMinOptLevel(1, x)
}
// Example snippet
pm::run_passes(
tcx,
body,
&[
&check_alignment::CheckAlignment,
&check_null::CheckNull,
...
&o1(simplify::SimplifyCfg::Final),
&strip_debuginfo::StripDebugInfo,
],
);
and there are no WithMinOptLevel(2, …) or higher anywhere in the MIR pass pipeline.
Questions:
- Where (if anywhere) is
mir-opt-level=2or higher actually used inside rustc? - Does setting
-Z mir-opt-level=2enable any additional MIR passes or change pass behavior internally?