-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Give OpTy access to locals for priroda #55179
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
Changes from 1 commit
ea51e32
3e62ba1
7d406c9
3742892
825b55e
f46e3ba
c32cf25
b178553
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
read_local_of_frame
in eval_place_to_op
Also make `layout_of_local` accept any `Frame`
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -571,6 +571,19 @@ 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 | ||
pub fn read_local_of_frame( | ||
&self, | ||
frame: &super::Frame<'mir, 'tcx, M::PointerTag>, | ||
local: mir::Local, | ||
layout: Option<TyLayout<'tcx>>, | ||
|
||
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { | ||
let op = *frame.locals[local].access()?; | ||
let layout = from_known_layout(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. | ||
|
@@ -582,12 +595,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> | |
use rustc::mir::Place::*; | ||
let op = match *mir_place { | ||
Local(mir::RETURN_PLACE) => return err!(ReadFromReturnPointer), | ||
Local(local) => { | ||
let op = *self.frame().locals[local].access()?; | ||
let layout = from_known_layout(layout, | ||
|| self.layout_of_local(self.cur_frame(), local))?; | ||
OpTy { op, layout } | ||
}, | ||
Local(local) => self.read_local_of_frame(self.frame(), local, layout)?, | ||
|
||
Projection(ref proj) => { | ||
let op = self.eval_place_to_op(&proj.base, None)?; | ||
|
@@ -772,16 +780,4 @@ 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 | ||
pub fn read_local_of_frame( | ||
&self, | ||
frame: &super::Frame<'mir, 'tcx>, | ||
local: mir::Local | ||
) -> EvalResult<'tcx, OpTy<'tcx>> { | ||
let op = *frame.locals[local].access()?; | ||
let local_ty = frame.mir.local_decls[local].ty; | ||
let local_ty = self.monomorphize(local_ty, frame.instance.substs); | ||
let layout = self.layout_of(local_ty)?; | ||
Ok(OpTy { op, layout }) | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.