Skip to content

Commit c060451

Browse files
committed
try to make layout_of_local less big
1 parent 7caf2cd commit c060451

File tree

1 file changed

+17
-8
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+17
-8
lines changed

compiler/rustc_const_eval/src/interpret/stack.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,16 +596,25 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
596596
return Ok(layout);
597597
}
598598

599-
let layout = from_known_layout(self.tcx, self.param_env, layout, || {
600-
let local_ty = frame.body.local_decls[local].ty;
601-
let local_ty =
602-
self.instantiate_from_frame_and_normalize_erasing_regions(frame, local_ty)?;
603-
self.layout_of(local_ty)
604-
})?;
605-
606599
// Layouts of locals are requested a lot, so we cache them.
600+
let layout = cold(self, frame, local, layout)?;
607601
state.layout.set(Some(layout));
608-
Ok(layout)
602+
return Ok(layout);
603+
604+
#[cold]
605+
fn cold<'tcx, M: Machine<'tcx>>(
606+
this: &InterpCx<'tcx, M>,
607+
frame: &Frame<'tcx, M::Provenance, M::FrameExtra>,
608+
local: mir::Local,
609+
layout: Option<TyAndLayout<'tcx>>,
610+
) -> InterpResult<'tcx, TyAndLayout<'tcx>> {
611+
from_known_layout(this.tcx, this.param_env, layout, || {
612+
let local_ty = frame.body.local_decls[local].ty;
613+
let local_ty =
614+
this.instantiate_from_frame_and_normalize_erasing_regions(frame, local_ty)?;
615+
this.layout_of(local_ty)
616+
})
617+
}
609618
}
610619
}
611620

0 commit comments

Comments
 (0)