@@ -141,7 +141,11 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
141
141
}
142
142
}
143
143
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 > {
145
149
let ecx = self . eval_context_ref ( ) ;
146
150
let mut global_state = ecx. machine . alloc_addresses . borrow_mut ( ) ;
147
151
let global_state = & mut * global_state;
@@ -283,16 +287,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
283
287
}
284
288
285
289
/// Convert a relative (tcx) pointer to a Miri pointer.
286
- fn ptr_from_rel_ptr (
290
+ fn adjust_alloc_base_pointer (
287
291
& self ,
288
292
ptr : Pointer < CtfeProvenance > ,
289
293
tag : BorTag ,
294
+ kind : MemoryKind ,
290
295
) -> InterpResult < ' tcx , Pointer < Provenance > > {
291
296
let ecx = self . eval_context_ref ( ) ;
292
297
293
298
let ( prov, offset) = ptr. into_parts ( ) ; // offset is relative (AllocId provenance)
294
299
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 ) ?;
296
301
297
302
// Add offset with the right kind of pointer-overflowing arithmetic.
298
303
let dl = ecx. data_layout ( ) ;
@@ -314,9 +319,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
314
319
ecx. alloc_id_from_addr ( addr. bytes ( ) ) ?
315
320
} ;
316
321
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
318
323
// 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 ( ) ;
320
325
321
326
// Wrapping "addr - base_addr"
322
327
#[ allow( clippy:: cast_possible_wrap) ] // we want to wrap here
0 commit comments