Skip to content

Commit

Permalink
Use optional values for inlining thresholds
Browse files Browse the repository at this point in the history
Turn inlining threshold into optional values to make it possible to
configure different defaults depending on the current mir-opt-level.
  • Loading branch information
tmiasko committed Feb 27, 2021
1 parent f895f1c commit 500aecc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ fn test_debugging_options_tracking_hash() {
tracked!(human_readable_cgu_names, true);
tracked!(inline_in_all_cgus, Some(true));
tracked!(inline_mir, Some(true));
tracked!(inline_mir_threshold, 123);
tracked!(inline_mir_hint_threshold, 123);
tracked!(inline_mir_threshold, Some(123));
tracked!(inline_mir_hint_threshold, Some(123));
tracked!(insert_sideeffect, true);
tracked!(instrument_coverage, true);
tracked!(instrument_mcount, true);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ impl Inliner<'tcx> {
let tcx = self.tcx;

let mut threshold = if callee_attrs.requests_inline() {
self.tcx.sess.opts.debugging_opts.inline_mir_hint_threshold
self.tcx.sess.opts.debugging_opts.inline_mir_hint_threshold.unwrap_or(100)
} else {
self.tcx.sess.opts.debugging_opts.inline_mir_threshold
self.tcx.sess.opts.debugging_opts.inline_mir_threshold.unwrap_or(50)
};

// Give a bonus functions with a small number of blocks,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"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: Option<usize> = (None, parse_opt_uint, [TRACKED],
"a default MIR inlining threshold (default: 50)"),
inline_mir_hint_threshold: usize = (100, parse_uint, [TRACKED],
inline_mir_hint_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
"inlining threshold for functions with inline hint (default: 100)"),
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
"control whether `#[inline]` functions are in all CGUs"),
Expand Down

0 comments on commit 500aecc

Please sign in to comment.