@@ -141,7 +141,11 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
141141 }
142142 }
143143
144- fn addr_from_alloc_id ( & self , alloc_id : AllocId ) -> InterpResult < ' tcx , u64 > {
144+ fn addr_from_alloc_id (
145+ & self ,
146+ alloc_id : AllocId ,
147+ _kind : MemoryKind ,
148+ ) -> InterpResult < ' tcx , u64 > {
145149 let ecx = self . eval_context_ref ( ) ;
146150 let mut global_state = ecx. machine . alloc_addresses . borrow_mut ( ) ;
147151 let global_state = & mut * global_state;
@@ -283,16 +287,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
283287 }
284288
285289 /// Convert a relative (tcx) pointer to a Miri pointer.
286- fn ptr_from_rel_ptr (
290+ fn adjust_alloc_base_pointer (
287291 & self ,
288292 ptr : Pointer < CtfeProvenance > ,
289293 tag : BorTag ,
294+ kind : MemoryKind ,
290295 ) -> InterpResult < ' tcx , Pointer < Provenance > > {
291296 let ecx = self . eval_context_ref ( ) ;
292297
293298 let ( prov, offset) = ptr. into_parts ( ) ; // offset is relative (AllocId provenance)
294299 let alloc_id = prov. alloc_id ( ) ;
295- let base_addr = ecx. addr_from_alloc_id ( alloc_id) ?;
300+ let base_addr = ecx. addr_from_alloc_id ( alloc_id, kind ) ?;
296301
297302 // Add offset with the right kind of pointer-overflowing arithmetic.
298303 let dl = ecx. data_layout ( ) ;
@@ -314,9 +319,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
314319 ecx. alloc_id_from_addr ( addr. bytes ( ) ) ?
315320 } ;
316321
317- // This cannot fail: since we already have a pointer with that provenance, rel_ptr_to_addr
322+ // This cannot fail: since we already have a pointer with that provenance, adjust_alloc_base_pointer
318323 // must have been called in the past, so we can just look up the address in the map.
319- let base_addr = ecx. addr_from_alloc_id ( alloc_id) . unwrap ( ) ;
324+ let base_addr = * ecx. machine . alloc_addresses . borrow ( ) . base_addr . get ( & alloc_id) . unwrap ( ) ;
320325
321326 // Wrapping "addr - base_addr"
322327 #[ allow( clippy:: cast_possible_wrap) ] // we want to wrap here
0 commit comments