|
2 | 2 | //! |
3 | 3 | //! The main entry point is the `step` method. |
4 | 4 |
|
5 | | -use crate::interpret::OpTy; |
6 | 5 | use rustc_middle::mir; |
7 | 6 | use rustc_middle::mir::interpret::{InterpResult, Scalar}; |
8 | 7 | use rustc_target::abi::LayoutOf; |
@@ -119,7 +118,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { |
119 | 118 | let src = self.eval_operand(src, None)?; |
120 | 119 | let dst = self.eval_operand(dst, None)?; |
121 | 120 | let count = self.eval_operand(count, None)?; |
122 | | - self.copy(&src, &dst, &count, /* nonoverlapping */ true)?; |
| 121 | + self.copy_intrinsic(&src, &dst, &count, /* nonoverlapping */ true)?; |
123 | 122 | } |
124 | 123 |
|
125 | 124 | // Statements we do not track. |
@@ -149,37 +148,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { |
149 | 148 | Ok(()) |
150 | 149 | } |
151 | 150 |
|
152 | | - pub(crate) fn copy( |
153 | | - &mut self, |
154 | | - src: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>, |
155 | | - dst: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>, |
156 | | - count: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>, |
157 | | - nonoverlapping: bool, |
158 | | - ) -> InterpResult<'tcx> { |
159 | | - let count = self.read_scalar(&count)?.to_machine_usize(self)?; |
160 | | - let layout = self.layout_of(src.layout.ty.builtin_deref(true).unwrap().ty)?; |
161 | | - let (size, align) = (layout.size, layout.align.abi); |
162 | | - let size = size.checked_mul(count, self).ok_or_else(|| { |
163 | | - err_ub_format!( |
164 | | - "overflow computing total size of `{}`", |
165 | | - if nonoverlapping { "copy_nonoverlapping" } else { "copy" } |
166 | | - ) |
167 | | - })?; |
168 | | - |
169 | | - // Make sure we check both pointers for an access of the total size and aligment, |
170 | | - // *even if* the total size is 0. |
171 | | - let src = |
172 | | - self.memory.check_ptr_access(self.read_scalar(&src)?.check_init()?, size, align)?; |
173 | | - |
174 | | - let dst = |
175 | | - self.memory.check_ptr_access(self.read_scalar(&dst)?.check_init()?, size, align)?; |
176 | | - |
177 | | - if let (Some(src), Some(dst)) = (src, dst) { |
178 | | - self.memory.copy(src, dst, size, nonoverlapping)?; |
179 | | - } |
180 | | - Ok(()) |
181 | | - } |
182 | | - |
183 | 151 | /// Evaluate an assignment statement. |
184 | 152 | /// |
185 | 153 | /// There is no separate `eval_rvalue` function. Instead, the code for handling each rvalue |
|
0 commit comments