@@ -444,7 +444,12 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
444
444
// `!` is a ZST and we want to validate it.
445
445
// Normalize before handing `place` to tracking because that will
446
446
// 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
+ } ;
448
453
let path = & self . path ;
449
454
ref_tracking. track ( place, || {
450
455
// 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>
578
583
let ty_size = self . ecx . layout_of ( tys) ?. size ;
579
584
// This is the size in bytes of the whole array.
580
585
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 ) ? ;
583
588
584
589
// NOTE: Keep this in sync with the handling of integer and float
585
590
// types above, in `visit_primitive`.
@@ -654,8 +659,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
654
659
ecx : self ,
655
660
} ;
656
661
662
+ // Try to cast to ptr *once* instead of all the time.
663
+ let op = self . force_op_ptr ( op) . unwrap_or ( op) ;
664
+
657
665
// Run it
658
- let op = self . normalize_op_ptr ( op) ?; // avoid doing ptr-to-int all the time
659
666
visitor. visit_value ( op)
660
667
}
661
668
}
0 commit comments