@@ -444,7 +444,12 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
444444 // `!` is a ZST and we want to validate it.
445445 // Normalize before handing `place` to tracking because that will
446446 // check for duplicates.
447- let place = self . ecx . normalize_mplace_ptr ( place) ?;
447+ let place = if size. bytes ( ) > 0 {
448+ self . ecx . force_mplace_ptr ( place)
449+ . expect ( "we already bounds-checked" )
450+ } else {
451+ place
452+ } ;
448453 let path = & self . path ;
449454 ref_tracking. track ( place, || {
450455 // We need to clone the path anyway, make sure it gets created
@@ -578,8 +583,8 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
578583 let ty_size = self . ecx . layout_of ( tys) ?. size ;
579584 // This is the size in bytes of the whole array.
580585 let size = ty_size * len;
581- // Size is not 0, get a pointer (no cast because we normalized in validate_operand) .
582- let ptr = mplace . ptr . assert_ptr ( ) ;
586+ // Size is not 0, get a pointer.
587+ let ptr = self . ecx . force_ptr ( mplace . ptr ) ? ;
583588
584589 // NOTE: Keep this in sync with the handling of integer and float
585590 // types above, in `visit_primitive`.
@@ -654,8 +659,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
654659 ecx : self ,
655660 } ;
656661
662+ // Try to cast to ptr *once* instead of all the time.
663+ let op = self . force_op_ptr ( op) . unwrap_or ( op) ;
664+
657665 // Run it
658- let op = self . normalize_op_ptr ( op) ?; // avoid doing ptr-to-int all the time
659666 visitor. visit_value ( op)
660667 }
661668}
0 commit comments