@@ -5,7 +5,7 @@ use std::collections::{hash_map::Entry, HashMap};
5
5
use rand:: Rng ;
6
6
7
7
use rustc:: ty:: layout:: HasDataLayout ;
8
- use rustc_mir:: interpret:: { AllocCheck , AllocId , InterpResult , Memory , Pointer , PointerArithmetic } ;
8
+ use rustc_mir:: interpret:: { AllocCheck , AllocId , InterpResult , Memory , Machine , Pointer , PointerArithmetic } ;
9
9
use rustc_target:: abi:: Size ;
10
10
11
11
use crate :: { Evaluator , Tag , STACK_ADDR } ;
@@ -80,12 +80,13 @@ impl<'mir, 'tcx> GlobalState {
80
80
) -> InterpResult < ' tcx , u64 > {
81
81
let mut global_state = memory. extra . intptrcast . borrow_mut ( ) ;
82
82
let global_state = & mut * global_state;
83
+ let id = Evaluator :: canonical_alloc_id ( memory, ptr. alloc_id ) ;
83
84
84
85
// There is nothing wrong with a raw pointer being cast to an integer only after
85
86
// it became dangling. Hence `MaybeDead`.
86
- let ( size, align) = memory. get_size_and_align ( ptr . alloc_id , AllocCheck :: MaybeDead ) ?;
87
+ let ( size, align) = memory. get_size_and_align ( id , AllocCheck :: MaybeDead ) ?;
87
88
88
- let base_addr = match global_state. base_addr . entry ( ptr . alloc_id ) {
89
+ let base_addr = match global_state. base_addr . entry ( id ) {
89
90
Entry :: Occupied ( entry) => * entry. get ( ) ,
90
91
Entry :: Vacant ( entry) => {
91
92
// This allocation does not have a base address yet, pick one.
@@ -102,7 +103,7 @@ impl<'mir, 'tcx> GlobalState {
102
103
trace ! (
103
104
"Assigning base address {:#x} to allocation {:?} (slack: {}, align: {})" ,
104
105
base_addr,
105
- ptr . alloc_id ,
106
+ id ,
106
107
slack,
107
108
align. bytes( ) ,
108
109
) ;
@@ -112,7 +113,7 @@ impl<'mir, 'tcx> GlobalState {
112
113
global_state. next_base_addr = base_addr. checked_add ( max ( size. bytes ( ) , 1 ) ) . unwrap ( ) ;
113
114
// Given that `next_base_addr` increases in each allocation, pushing the
114
115
// corresponding tuple keeps `int_to_ptr_map` sorted
115
- global_state. int_to_ptr_map . push ( ( base_addr, ptr . alloc_id ) ) ;
116
+ global_state. int_to_ptr_map . push ( ( base_addr, id ) ) ;
116
117
117
118
base_addr
118
119
}
0 commit comments