@@ -504,15 +504,13 @@ where
504504 & self ,
505505 local : mir:: Local ,
506506 ) -> 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.
509507 let frame = self . frame ( ) ;
510508 let layout = self . layout_of_local ( frame, local, None ) ?;
511509 let place = if layout. is_sized ( ) {
512510 // We can just always use the `Local` for sized values.
513511 Place :: Local { local, offset : None , locals_addr : frame. locals_addr ( ) }
514512 } 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 .
516514 match frame. locals [ local] . access ( ) ? {
517515 Operand :: Immediate ( _) => bug ! ( ) ,
518516 Operand :: Indirect ( mplace) => Place :: Ptr ( * mplace) ,
@@ -565,7 +563,10 @@ where
565563 place : & PlaceTy < ' tcx , M :: Provenance > ,
566564 ) -> InterpResult <
567565 ' 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+ > ,
569570 > {
570571 Ok ( match place. to_place ( ) . as_mplace_or_local ( ) {
571572 Left ( mplace) => Left ( mplace) ,
@@ -584,7 +585,7 @@ where
584585 }
585586 Operand :: Immediate ( local_val) => {
586587 // The local still has the optimized representation.
587- Right ( ( local_val, layout) )
588+ Right ( ( local_val, layout, local ) )
588589 }
589590 }
590591 }
@@ -646,9 +647,13 @@ where
646647 assert ! ( dest. layout( ) . is_sized( ) , "Cannot write unsized immediate data" ) ;
647648
648649 match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
649- Right ( ( local_val, local_layout) ) => {
650+ Right ( ( local_val, local_layout, local ) ) => {
650651 // Local can be updated in-place.
651652 * 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+ }
652657 // Double-check that the value we are storing and the local fit to each other.
653658 if cfg ! ( debug_assertions) {
654659 src. assert_matches_abi ( local_layout. abi , self ) ;
@@ -717,8 +722,12 @@ where
717722 dest : & impl Writeable < ' tcx , M :: Provenance > ,
718723 ) -> InterpResult < ' tcx > {
719724 match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
720- Right ( ( local_val, _local_layout) ) => {
725+ Right ( ( local_val, _local_layout, local ) ) => {
721726 * 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+ }
722731 }
723732 Left ( mplace) => {
724733 let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -737,8 +746,12 @@ where
737746 dest : & impl Writeable < ' tcx , M :: Provenance > ,
738747 ) -> InterpResult < ' tcx > {
739748 match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
740- Right ( ( local_val, _local_layout) ) => {
749+ Right ( ( local_val, _local_layout, local ) ) => {
741750 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+ }
742755 }
743756 Left ( mplace) => {
744757 let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -944,7 +957,7 @@ where
944957 mplace. mplace ,
945958 ) ?;
946959 }
947- M :: after_local_allocated ( self , local, & mplace) ?;
960+ M :: after_local_moved_to_memory ( self , local, & mplace) ?;
948961 // Now we can call `access_mut` again, asserting it goes well, and actually
949962 // overwrite things. This points to the entire allocation, not just the part
950963 // the place refers to, i.e. we do this before we apply `offset`.
0 commit comments