Skip to content

Commit 6628215

Browse files
committed
Miri changes for rustc permissive provenance
1 parent 5887b2b commit 6628215

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/machine.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ impl Provenance for Tag {
158158
write!(f, "{:?}", tag.sb)
159159
}
160160

161-
fn get_alloc_id(self) -> AllocId {
162-
self.alloc_id
161+
fn get_alloc_id(self) -> Option<AllocId> {
162+
Some(self.alloc_id)
163163
}
164164
}
165165

@@ -604,21 +604,37 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
604604
}
605605

606606
#[inline(always)]
607-
fn ptr_from_addr(
607+
fn ptr_from_addr_cast(
608608
ecx: &MiriEvalContext<'mir, 'tcx>,
609609
addr: u64,
610610
) -> Pointer<Option<Self::PointerTag>> {
611611
intptrcast::GlobalStateInner::ptr_from_addr(addr, ecx)
612612
}
613613

614+
#[inline(always)]
615+
fn ptr_from_addr_transmute(
616+
ecx: &MiriEvalContext<'mir, 'tcx>,
617+
addr: u64,
618+
) -> Pointer<Option<Self::PointerTag>> {
619+
Self::ptr_from_addr_cast(ecx, addr)
620+
}
621+
622+
#[inline(always)]
623+
fn expose_ptr(
624+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
625+
ptr: Pointer<Self::PointerTag>,
626+
) -> InterpResult<'tcx> {
627+
Ok(())
628+
}
629+
614630
/// Convert a pointer with provenance into an allocation-offset pair,
615631
/// or a `None` with an absolute address if that conversion is not possible.
616632
fn ptr_get_alloc(
617633
ecx: &MiriEvalContext<'mir, 'tcx>,
618634
ptr: Pointer<Self::PointerTag>,
619-
) -> (AllocId, Size, Self::TagExtra) {
635+
) -> Option<(AllocId, Size, Self::TagExtra)> {
620636
let rel = intptrcast::GlobalStateInner::abs_ptr_to_rel(ecx, ptr);
621-
(ptr.provenance.alloc_id, rel, ptr.provenance.sb)
637+
Some((ptr.provenance.alloc_id, rel, ptr.provenance.sb))
622638
}
623639

624640
#[inline(always)]

0 commit comments

Comments
 (0)