ctfe interning: don't walk allocations that don't need it
The interning of const allocations visits the mplace looking for references to intern. Walking big aggregates like big static arrays can be costly, so we only do it if the allocation we're interning contains references or interior mutability. Walking ZSTs was avoided before, and this optimization is now applied to cases where there are no references/relocations either.
This commit is contained in:
@@ -942,6 +942,11 @@ impl<'tcx, 'a, Tag: Provenance, Extra> AllocRef<'a, 'tcx, Tag, Extra> {
|
||||
.check_bytes(&self.tcx, self.range.subrange(range), allow_uninit, allow_ptr)
|
||||
.map_err(|e| e.to_interp_error(self.alloc_id))?)
|
||||
}
|
||||
|
||||
/// Returns whether the allocation has relocations for the entire range of the `AllocRef`.
|
||||
pub(crate) fn has_relocations(&self) -> bool {
|
||||
!self.alloc.get_relocations(&self.tcx, self.range).is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
|
||||
Reference in New Issue
Block a user