remove a now-useless machine hook
This commit is contained in:
parent
4173e971b8
commit
aff9841507
4 changed files with 5 additions and 33 deletions
|
@ -187,9 +187,6 @@ pub enum LocalValue<Prov: Provenance = AllocId> {
|
||||||
|
|
||||||
impl<'tcx, Prov: Provenance + 'static> LocalState<'tcx, Prov> {
|
impl<'tcx, Prov: Provenance + 'static> LocalState<'tcx, Prov> {
|
||||||
/// Read the local's value or error if the local is not yet live or not live anymore.
|
/// Read the local's value or error if the local is not yet live or not live anymore.
|
||||||
///
|
|
||||||
/// Note: This may only be invoked from the `Machine::access_local` hook and not from
|
|
||||||
/// anywhere else. You may be invalidating machine invariants if you do!
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn access(&self) -> InterpResult<'tcx, &Operand<Prov>> {
|
pub fn access(&self) -> InterpResult<'tcx, &Operand<Prov>> {
|
||||||
match &self.value {
|
match &self.value {
|
||||||
|
|
|
@ -215,23 +215,12 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
||||||
right: &ImmTy<'tcx, Self::Provenance>,
|
right: &ImmTy<'tcx, Self::Provenance>,
|
||||||
) -> InterpResult<'tcx, (Scalar<Self::Provenance>, bool, Ty<'tcx>)>;
|
) -> InterpResult<'tcx, (Scalar<Self::Provenance>, bool, Ty<'tcx>)>;
|
||||||
|
|
||||||
/// Called to read the specified `local` from the `frame`.
|
|
||||||
/// Since reading a ZST is not actually accessing memory or locals, this is never invoked
|
|
||||||
/// for ZST reads.
|
|
||||||
#[inline]
|
|
||||||
fn access_local<'a>(
|
|
||||||
frame: &'a Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>,
|
|
||||||
local: mir::Local,
|
|
||||||
) -> InterpResult<'tcx, &'a Operand<Self::Provenance>>
|
|
||||||
where
|
|
||||||
'tcx: 'mir,
|
|
||||||
{
|
|
||||||
frame.locals[local].access()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Called to write the specified `local` from the `frame`.
|
/// Called to write the specified `local` from the `frame`.
|
||||||
/// Since writing a ZST is not actually accessing memory or locals, this is never invoked
|
/// Since writing a ZST is not actually accessing memory or locals, this is never invoked
|
||||||
/// for ZST reads.
|
/// for ZST reads.
|
||||||
|
///
|
||||||
|
/// Due to borrow checker trouble, we indicate the `frame` as an index rather than an `&mut
|
||||||
|
/// Frame`.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn access_local_mut<'a>(
|
fn access_local_mut<'a>(
|
||||||
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
||||||
|
|
|
@ -444,7 +444,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read from a local. Will not actually access the local if reading from a ZST.
|
/// Read from a local.
|
||||||
/// Will not access memory, instead an indirect `Operand` is returned.
|
/// Will not access memory, instead an indirect `Operand` is returned.
|
||||||
///
|
///
|
||||||
/// This is public because it is used by [priroda](https://github.com/oli-obk/priroda) to get an
|
/// This is public because it is used by [priroda](https://github.com/oli-obk/priroda) to get an
|
||||||
|
@ -456,12 +456,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
layout: Option<TyAndLayout<'tcx>>,
|
layout: Option<TyAndLayout<'tcx>>,
|
||||||
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
|
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
|
||||||
let layout = self.layout_of_local(frame, local, layout)?;
|
let layout = self.layout_of_local(frame, local, layout)?;
|
||||||
let op = if layout.is_zst() {
|
let op = *frame.locals[local].access()?;
|
||||||
// Bypass `access_local` (helps in ConstProp)
|
|
||||||
Operand::Immediate(Immediate::Uninit)
|
|
||||||
} else {
|
|
||||||
*M::access_local(frame, local)?
|
|
||||||
};
|
|
||||||
Ok(OpTy { op, layout, align: Some(layout.align.abi) })
|
Ok(OpTy { op, layout, align: Some(layout.align.abi) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,15 +243,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
|
||||||
throw_machine_stop_str!("pointer arithmetic or comparisons aren't supported in ConstProp")
|
throw_machine_stop_str!("pointer arithmetic or comparisons aren't supported in ConstProp")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn access_local<'a>(
|
|
||||||
frame: &'a Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>,
|
|
||||||
local: Local,
|
|
||||||
) -> InterpResult<'tcx, &'a interpret::Operand<Self::Provenance>> {
|
|
||||||
let l = &frame.locals[local];
|
|
||||||
// Applying restrictions here is meaningless since they can be circumvented via `force_allocation`.
|
|
||||||
l.access()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn access_local_mut<'a>(
|
fn access_local_mut<'a>(
|
||||||
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
||||||
frame: usize,
|
frame: usize,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue