diff options
| author | Ralf Jung <post@ralfj.de> | 2020-02-23 19:50:34 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-02-23 19:50:34 +0100 |
| commit | 01d932934748ef5c412c11a2ace18a504a7cb949 (patch) | |
| tree | d4a0f7514749ceee068065f3452621ce884acfd9 | |
| parent | 5da393970df87f13881fd1f8cebd9b2a42659759 (diff) | |
| download | rust-01d932934748ef5c412c11a2ace18a504a7cb949.tar.gz rust-01d932934748ef5c412c11a2ace18a504a7cb949.zip | |
canonicalize alloc ID before calling tag_static_base_pointer
| -rw-r--r-- | src/librustc_mir/interpret/machine.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 98a305ec2d9..11d28ec582a 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -253,6 +253,8 @@ pub trait Machine<'mir, 'tcx>: Sized { /// Return the "base" tag for the given *static* allocation: the one that is used for direct /// accesses to this static/const/fn allocation. If `id` is not a static allocation, /// this will return an unusable tag (i.e., accesses will be UB)! + /// + /// Expects `id` to be already canonical, if needed. fn tag_static_base_pointer(memory_extra: &Self::MemoryExtra, id: AllocId) -> Self::PointerTag; /// Executes a retagging operation diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 048c5d7b159..f60307e468b 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -150,7 +150,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { /// through a pointer that was created by the program. #[inline] pub fn tag_static_base_pointer(&self, ptr: Pointer) -> Pointer<M::PointerTag> { - ptr.with_tag(M::tag_static_base_pointer(&self.extra, ptr.alloc_id)) + let id = M::canonical_alloc_id(self, ptr.alloc_id); + ptr.with_tag(M::tag_static_base_pointer(&self.extra, id)) } pub fn create_fn_alloc( |
