diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-12 16:17:06 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-25 06:46:48 +0000 |
| commit | f08dc9be17aff80e248d37a768faa6cc8738d371 (patch) | |
| tree | 78fb39db49a4ded80b787b69bdfa38560d46b1b3 | |
| parent | e3538d11f1ca94737e21676a54f8de65523d614c (diff) | |
| download | rust-f08dc9be17aff80e248d37a768faa6cc8738d371.tar.gz rust-f08dc9be17aff80e248d37a768faa6cc8738d371.zip | |
Take an AllocId in intern_const_alloc_for_constprop.
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intern.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/gvn.rs | 9 |
2 files changed, 3 insertions, 9 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index 0d21ef7f327..23d6d321947 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -459,10 +459,9 @@ pub fn intern_const_alloc_for_constprop< M: CompileTimeMachine<'mir, 'tcx, T>, >( ecx: &mut InterpCx<'mir, 'tcx, M>, - ret: &MPlaceTy<'tcx>, + alloc_id: AllocId, ) -> InterpResult<'tcx, ()> { // Move allocation to `tcx`. - let alloc_id = ret.ptr().provenance.unwrap(); let Some((_, mut alloc)) = ecx.memory.alloc_map.remove(&alloc_id) else { // Pointer not found in local memory map. It is either a pointer to the global // map, or dangling. diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index c575da611c7..58844aed783 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -61,7 +61,6 @@ use rustc_hir::def::DefKind; use rustc_index::bit_set::BitSet; use rustc_index::IndexVec; use rustc_macros::newtype_index; -use rustc_middle::mir::interpret::GlobalAlloc; use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::layout::LayoutOf; @@ -861,14 +860,10 @@ fn op_to_prop_const<'tcx>( return None; } - intern_const_alloc_for_constprop(ecx, &mplace).ok()?; let pointer = mplace.ptr().into_pointer_or_addr().ok()?; let (alloc_id, offset) = pointer.into_parts(); - match ecx.tcx.global_alloc(alloc_id) { - GlobalAlloc::Memory(_) => return Some(ConstValue::Indirect { alloc_id, offset }), - // Fallthrough to copying the data. - _ => {} - } + intern_const_alloc_for_constprop(ecx, alloc_id).ok()?; + return Some(ConstValue::Indirect { alloc_id, offset }); } // Everything failed: create a new allocation to hold the data. |
