Add option enabling MIR inlining independently of mir-opt-level
This commit is contained in:
parent
0846043440
commit
f895f1c35a
4 changed files with 23 additions and 15 deletions
|
@ -557,6 +557,7 @@ fn test_debugging_options_tracking_hash() {
|
||||||
tracked!(function_sections, Some(false));
|
tracked!(function_sections, Some(false));
|
||||||
tracked!(human_readable_cgu_names, true);
|
tracked!(human_readable_cgu_names, true);
|
||||||
tracked!(inline_in_all_cgus, Some(true));
|
tracked!(inline_in_all_cgus, Some(true));
|
||||||
|
tracked!(inline_mir, Some(true));
|
||||||
tracked!(inline_mir_threshold, 123);
|
tracked!(inline_mir_threshold, 123);
|
||||||
tracked!(inline_mir_hint_threshold, 123);
|
tracked!(inline_mir_hint_threshold, 123);
|
||||||
tracked!(insert_sideeffect, true);
|
tracked!(insert_sideeffect, true);
|
||||||
|
|
|
@ -37,21 +37,27 @@ struct CallSite<'tcx> {
|
||||||
source_info: SourceInfo,
|
source_info: SourceInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> MirPass<'tcx> for Inline {
|
/// Returns true if MIR inlining is enabled in the current compilation session.
|
||||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
crate fn is_enabled(tcx: TyCtxt<'_>) -> bool {
|
||||||
// If you change this optimization level, also change the level in
|
|
||||||
// `mir_drops_elaborated_and_const_checked` for the call to `mir_inliner_callees`.
|
|
||||||
// Otherwise you will get an ICE about stolen MIR.
|
|
||||||
if tcx.sess.opts.debugging_opts.mir_opt_level < 2 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if tcx.sess.opts.debugging_opts.instrument_coverage {
|
if tcx.sess.opts.debugging_opts.instrument_coverage {
|
||||||
// Since `Inline` happens after `InstrumentCoverage`, the function-specific coverage
|
// Since `Inline` happens after `InstrumentCoverage`, the function-specific coverage
|
||||||
// counters can be invalidated, such as by merging coverage counter statements from
|
// counters can be invalidated, such as by merging coverage counter statements from
|
||||||
// a pre-inlined function into a different function. This kind of change is invalid,
|
// a pre-inlined function into a different function. This kind of change is invalid,
|
||||||
// so inlining must be skipped. Note: This check is performed here so inlining can
|
// so inlining must be skipped. Note: This check is performed here so inlining can
|
||||||
// be disabled without preventing other optimizations (regardless of `mir_opt_level`).
|
// be disabled without preventing other optimizations (regardless of `mir_opt_level`).
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(enabled) = tcx.sess.opts.debugging_opts.inline_mir {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcx.sess.opts.debugging_opts.mir_opt_level >= 2
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> MirPass<'tcx> for Inline {
|
||||||
|
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
|
if !is_enabled(tcx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -429,8 +429,7 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
|
||||||
let def = ty::WithOptConstParam::unknown(did);
|
let def = ty::WithOptConstParam::unknown(did);
|
||||||
|
|
||||||
// Do not compute the mir call graph without said call graph actually being used.
|
// Do not compute the mir call graph without said call graph actually being used.
|
||||||
// Keep this in sync with the mir inliner's optimization level.
|
if inline::is_enabled(tcx) {
|
||||||
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
|
|
||||||
let _ = tcx.mir_inliner_callees(ty::InstanceDef::Item(def));
|
let _ = tcx.mir_inliner_callees(ty::InstanceDef::Item(def));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -957,6 +957,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
(default: no)"),
|
(default: no)"),
|
||||||
incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
|
incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"verify incr. comp. hashes of green query instances (default: no)"),
|
"verify incr. comp. hashes of green query instances (default: no)"),
|
||||||
|
inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||||
|
"enable MIR inlining (default: no)"),
|
||||||
inline_mir_threshold: usize = (50, parse_uint, [TRACKED],
|
inline_mir_threshold: usize = (50, parse_uint, [TRACKED],
|
||||||
"a default MIR inlining threshold (default: 50)"),
|
"a default MIR inlining threshold (default: 50)"),
|
||||||
inline_mir_hint_threshold: usize = (100, parse_uint, [TRACKED],
|
inline_mir_hint_threshold: usize = (100, parse_uint, [TRACKED],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue