@@ -500,15 +500,13 @@ where
500500 & self ,
501501 local : mir:: Local ,
502502 ) -> InterpResult < ' tcx , PlaceTy < ' tcx , M :: Provenance > > {
503- // Other parts of the system rely on `Place::Local` never being unsized.
504- // So we eagerly check here if this local has an MPlace, and if yes we use it.
505503 let frame = self . frame ( ) ;
506504 let layout = self . layout_of_local ( frame, local, None ) ?;
507505 let place = if layout. is_sized ( ) {
508506 // We can just always use the `Local` for sized values.
509507 Place :: Local { local, offset : None , locals_addr : frame. locals_addr ( ) }
510508 } else {
511- // Unsized `Local` isn't okay (we cannot store the metadata) .
509+ // Other parts of the system rely on `Place::Local` never being unsized .
512510 match frame. locals [ local] . access ( ) ? {
513511 Operand :: Immediate ( _) => bug ! ( ) ,
514512 Operand :: Indirect ( mplace) => Place :: Ptr ( * mplace) ,
@@ -562,7 +560,10 @@ where
562560 place : & PlaceTy < ' tcx , M :: Provenance > ,
563561 ) -> InterpResult <
564562 ' tcx ,
565- Either < MPlaceTy < ' tcx , M :: Provenance > , ( & mut Immediate < M :: Provenance > , TyAndLayout < ' tcx > ) > ,
563+ Either <
564+ MPlaceTy < ' tcx , M :: Provenance > ,
565+ ( & mut Immediate < M :: Provenance > , TyAndLayout < ' tcx > , mir:: Local ) ,
566+ > ,
566567 > {
567568 Ok ( match place. to_place ( ) . as_mplace_or_local ( ) {
568569 Left ( mplace) => Left ( mplace) ,
@@ -581,7 +582,7 @@ where
581582 }
582583 Operand :: Immediate ( local_val) => {
583584 // The local still has the optimized representation.
584- Right ( ( local_val, layout) )
585+ Right ( ( local_val, layout, local ) )
585586 }
586587 }
587588 }
@@ -643,9 +644,13 @@ where
643644 assert ! ( dest. layout( ) . is_sized( ) , "Cannot write unsized immediate data" ) ;
644645
645646 match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
646- Right ( ( local_val, local_layout) ) => {
647+ Right ( ( local_val, local_layout, local ) ) => {
647648 // Local can be updated in-place.
648649 * local_val = src;
650+ // Call the machine hook (the data race detector needs to know about this write).
651+ if !self . validation_in_progress ( ) {
652+ M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
653+ }
649654 // Double-check that the value we are storing and the local fit to each other.
650655 if cfg ! ( debug_assertions) {
651656 src. assert_matches_abi ( local_layout. abi , self ) ;
@@ -714,8 +719,12 @@ where
714719 dest : & impl Writeable < ' tcx , M :: Provenance > ,
715720 ) -> InterpResult < ' tcx > {
716721 match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
717- Right ( ( local_val, _local_layout) ) => {
722+ Right ( ( local_val, _local_layout, local ) ) => {
718723 * local_val = Immediate :: Uninit ;
724+ // Call the machine hook (the data race detector needs to know about this write).
725+ if !self . validation_in_progress ( ) {
726+ M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
727+ }
719728 }
720729 Left ( mplace) => {
721730 let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -734,8 +743,12 @@ where
734743 dest : & impl Writeable < ' tcx , M :: Provenance > ,
735744 ) -> InterpResult < ' tcx > {
736745 match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
737- Right ( ( local_val, _local_layout) ) => {
746+ Right ( ( local_val, _local_layout, local ) ) => {
738747 local_val. clear_provenance ( ) ?;
748+ // Call the machine hook (the data race detector needs to know about this write).
749+ if !self . validation_in_progress ( ) {
750+ M :: after_local_write ( self , local, /*storage_live*/ false ) ?;
751+ }
739752 }
740753 Left ( mplace) => {
741754 let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -941,7 +954,7 @@ where
941954 mplace. mplace ,
942955 ) ?;
943956 }
944- M :: after_local_allocated ( self , local, & mplace) ?;
957+ M :: after_local_moved_to_memory ( self , local, & mplace) ?;
945958 // Now we can call `access_mut` again, asserting it goes well, and actually
946959 // overwrite things. This points to the entire allocation, not just the part
947960 // the place refers to, i.e. we do this before we apply `offset`.
0 commit comments