Skip to content

Commit

Permalink
Rollup merge of rust-lang#55739 - wesleywiser:mir_inline_fuel, r=niko…
Browse files Browse the repository at this point in the history
…matsakis

Consume optimization fuel from the MIR inliner

This makes it easier to debug mis-optimizations that occur during
inlining. Thanks to @nikomatsakis for the suggestion!
  • Loading branch information
kennytm committed Nov 8, 2018
2 parents 4feb4f9 + e72afa9 commit d54a039
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/librustc_mir/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {

let callee_mir = match self.tcx.try_optimized_mir(callsite.location.span,
callsite.callee) {
Ok(callee_mir) if self.should_inline(callsite, callee_mir) => {
Ok(callee_mir) if self.consider_optimizing(callsite, callee_mir) => {
self.tcx.subst_and_normalize_erasing_regions(
&callsite.substs,
param_env,
Expand Down Expand Up @@ -198,6 +198,18 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
}
}

fn consider_optimizing(&self,
callsite: CallSite<'tcx>,
callee_mir: &Mir<'tcx>)
-> bool
{
debug!("consider_optimizing({:?})", callsite);
self.should_inline(callsite, callee_mir)
&& self.tcx.consider_optimizing(|| format!("Inline {:?} into {:?}",
callee_mir.span,
callsite))
}

fn should_inline(&self,
callsite: CallSite<'tcx>,
callee_mir: &Mir<'tcx>)
Expand Down

0 comments on commit d54a039

Please sign in to comment.