@@ -504,15 +504,13 @@ where
504
504
& self ,
505
505
local : mir:: Local ,
506
506
) -> InterpResult < ' tcx , PlaceTy < ' tcx , M :: Provenance > > {
507
- // Other parts of the system rely on `Place::Local` never being unsized.
508
- // So we eagerly check here if this local has an MPlace, and if yes we use it.
509
507
let frame = self . frame ( ) ;
510
508
let layout = self . layout_of_local ( frame, local, None ) ?;
511
509
let place = if layout. is_sized ( ) {
512
510
// We can just always use the `Local` for sized values.
513
511
Place :: Local { local, offset : None , locals_addr : frame. locals_addr ( ) }
514
512
} else {
515
- // Unsized `Local` isn't okay (we cannot store the metadata) .
513
+ // Other parts of the system rely on `Place::Local` never being unsized .
516
514
match frame. locals [ local] . access ( ) ? {
517
515
Operand :: Immediate ( _) => bug ! ( ) ,
518
516
Operand :: Indirect ( mplace) => Place :: Ptr ( * mplace) ,
@@ -565,7 +563,10 @@ where
565
563
place : & PlaceTy < ' tcx , M :: Provenance > ,
566
564
) -> InterpResult <
567
565
' tcx ,
568
- Either < MPlaceTy < ' tcx , M :: Provenance > , ( & mut Immediate < M :: Provenance > , TyAndLayout < ' tcx > ) > ,
566
+ Either <
567
+ MPlaceTy < ' tcx , M :: Provenance > ,
568
+ ( & mut Immediate < M :: Provenance > , TyAndLayout < ' tcx > , mir:: Local ) ,
569
+ > ,
569
570
> {
570
571
Ok ( match place. to_place ( ) . as_mplace_or_local ( ) {
571
572
Left ( mplace) => Left ( mplace) ,
@@ -584,7 +585,7 @@ where
584
585
}
585
586
Operand :: Immediate ( local_val) => {
586
587
// The local still has the optimized representation.
587
- Right ( ( local_val, layout) )
588
+ Right ( ( local_val, layout, local ) )
588
589
}
589
590
}
590
591
}
@@ -646,9 +647,13 @@ where
646
647
assert ! ( dest. layout( ) . is_sized( ) , "Cannot write unsized immediate data" ) ;
647
648
648
649
match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
649
- Right ( ( local_val, local_layout) ) => {
650
+ Right ( ( local_val, local_layout, local ) ) => {
650
651
// Local can be updated in-place.
651
652
* local_val = src;
653
+ // Call the machine hook (the data race detector needs to know about this write).
654
+ if !self . validation_in_progress ( ) {
655
+ M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
656
+ }
652
657
// Double-check that the value we are storing and the local fit to each other.
653
658
if cfg ! ( debug_assertions) {
654
659
src. assert_matches_abi ( local_layout. abi , self ) ;
@@ -717,8 +722,12 @@ where
717
722
dest : & impl Writeable < ' tcx , M :: Provenance > ,
718
723
) -> InterpResult < ' tcx > {
719
724
match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
720
- Right ( ( local_val, _local_layout) ) => {
725
+ Right ( ( local_val, _local_layout, local ) ) => {
721
726
* local_val = Immediate :: Uninit ;
727
+ // Call the machine hook (the data race detector needs to know about this write).
728
+ if !self . validation_in_progress ( ) {
729
+ M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
730
+ }
722
731
}
723
732
Left ( mplace) => {
724
733
let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -737,8 +746,12 @@ where
737
746
dest : & impl Writeable < ' tcx , M :: Provenance > ,
738
747
) -> InterpResult < ' tcx > {
739
748
match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
740
- Right ( ( local_val, _local_layout) ) => {
749
+ Right ( ( local_val, _local_layout, local ) ) => {
741
750
local_val. clear_provenance ( ) ?;
751
+ // Call the machine hook (the data race detector needs to know about this write).
752
+ if !self . validation_in_progress ( ) {
753
+ M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
754
+ }
742
755
}
743
756
Left ( mplace) => {
744
757
let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -944,7 +957,7 @@ where
944
957
mplace. mplace ,
945
958
) ?;
946
959
}
947
- M :: after_local_allocated ( self , local, & mplace) ?;
960
+ M :: after_local_moved_to_memory ( self , local, & mplace) ?;
948
961
// Now we can call `access_mut` again, asserting it goes well, and actually
949
962
// overwrite things. This points to the entire allocation, not just the part
950
963
// the place refers to, i.e. we do this before we apply `offset`.
0 commit comments