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!
This commit is contained in:
Wesley Wiser 2018-10-21 11:58:39 -04:00
parent ddd4b194a0
commit e72afa9573

View file

@ -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,
@ -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>)