-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const_eval: Predetermine the layout of all locals when pushing a stack frame #57677
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,36 +457,30 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> | |
} | ||
|
||
/// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local | ||
/// | ||
/// When you know the layout of the local in advance, you can pass it as last argument | ||
pub fn access_local( | ||
fn access_local( | ||
&self, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drive-by fix: |
||
frame: &super::Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>, | ||
local: mir::Local, | ||
layout: Option<TyLayout<'tcx>>, | ||
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { | ||
assert_ne!(local, mir::RETURN_PLACE); | ||
let op = *frame.locals[local].access()?; | ||
let layout = from_known_layout(layout, | ||
|| self.layout_of_local(frame, local))?; | ||
let layout = self.layout_of_local(frame, local)?; | ||
Ok(OpTy { op, layout }) | ||
} | ||
|
||
// Evaluate a place with the goal of reading from it. This lets us sometimes | ||
// avoid allocations. If you already know the layout, you can pass it in | ||
// to avoid looking it up again. | ||
// avoid allocations. | ||
fn eval_place_to_op( | ||
&self, | ||
mir_place: &mir::Place<'tcx>, | ||
layout: Option<TyLayout<'tcx>>, | ||
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { | ||
use rustc::mir::Place::*; | ||
let op = match *mir_place { | ||
Local(mir::RETURN_PLACE) => return err!(ReadFromReturnPointer), | ||
Local(local) => self.access_local(self.frame(), local, layout)?, | ||
Local(local) => self.access_local(self.frame(), local)?, | ||
|
||
Projection(ref proj) => { | ||
let op = self.eval_place_to_op(&proj.base, None)?; | ||
let op = self.eval_place_to_op(&proj.base)?; | ||
self.operand_projection(op, &proj.elem)? | ||
} | ||
|
||
|
@@ -510,7 +504,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> | |
// FIXME: do some more logic on `move` to invalidate the old location | ||
Copy(ref place) | | ||
Move(ref place) => | ||
self.eval_place_to_op(place, layout)?, | ||
self.eval_place_to_op(place)?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, but this means we might have to compute the layout even if we already know it, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To change this we'd need to pass a precomputed layout to |
||
|
||
Constant(ref constant) => { | ||
let layout = from_known_layout(layout, || { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the information be included in
locals
itself?