Skip to content

Commit 7d63e43

Browse files
committed
perf: don't deinit protected fn args
1 parent 33a2c24 commit 7d63e43

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,17 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
421421
/// Called on places used for in-place function argument and return value handling.
422422
///
423423
/// These places need to be protected to make sure the program cannot tell whether the
424-
/// argument/return value was actually copied or passed in-place..
424+
/// argument/return value was actually copied or passed in-place.
425425
fn protect_in_place_function_argument(
426426
ecx: &mut InterpCx<'mir, 'tcx, Self>,
427427
place: &PlaceTy<'tcx, Self::Provenance>,
428428
) -> InterpResult<'tcx> {
429429
// Without an aliasing model, all we can do is put `Uninit` into the place.
430-
ecx.write_uninit(place)
430+
// This can only be violated with custom MIR though so we avoid the perf hit.
431+
if ecx.tcx.sess.opts.unstable_opts.extra_const_ub_checks {
432+
ecx.write_uninit(place)?;
433+
}
434+
Ok(())
431435
}
432436

433437
/// Called immediately before a new stack frame gets pushed.

0 commit comments

Comments
 (0)