@@ -500,15 +500,13 @@ where
500
500
& self ,
501
501
local : mir:: Local ,
502
502
) -> 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.
505
503
let frame = self . frame ( ) ;
506
504
let layout = self . layout_of_local ( frame, local, None ) ?;
507
505
let place = if layout. is_sized ( ) {
508
506
// We can just always use the `Local` for sized values.
509
507
Place :: Local { local, offset : None , locals_addr : frame. locals_addr ( ) }
510
508
} 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 .
512
510
match frame. locals [ local] . access ( ) ? {
513
511
Operand :: Immediate ( _) => bug ! ( ) ,
514
512
Operand :: Indirect ( mplace) => Place :: Ptr ( * mplace) ,
@@ -562,7 +560,10 @@ where
562
560
place : & PlaceTy < ' tcx , M :: Provenance > ,
563
561
) -> InterpResult <
564
562
' 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
+ > ,
566
567
> {
567
568
Ok ( match place. to_place ( ) . as_mplace_or_local ( ) {
568
569
Left ( mplace) => Left ( mplace) ,
@@ -581,7 +582,7 @@ where
581
582
}
582
583
Operand :: Immediate ( local_val) => {
583
584
// The local still has the optimized representation.
584
- Right ( ( local_val, layout) )
585
+ Right ( ( local_val, layout, local ) )
585
586
}
586
587
}
587
588
}
@@ -643,9 +644,13 @@ where
643
644
assert ! ( dest. layout( ) . is_sized( ) , "Cannot write unsized immediate data" ) ;
644
645
645
646
match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
646
- Right ( ( local_val, local_layout) ) => {
647
+ Right ( ( local_val, local_layout, local ) ) => {
647
648
// Local can be updated in-place.
648
649
* 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
+ }
649
654
// Double-check that the value we are storing and the local fit to each other.
650
655
if cfg ! ( debug_assertions) {
651
656
src. assert_matches_abi ( local_layout. abi , self ) ;
@@ -714,8 +719,12 @@ where
714
719
dest : & impl Writeable < ' tcx , M :: Provenance > ,
715
720
) -> InterpResult < ' tcx > {
716
721
match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
717
- Right ( ( local_val, _local_layout) ) => {
722
+ Right ( ( local_val, _local_layout, local ) ) => {
718
723
* 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
+ }
719
728
}
720
729
Left ( mplace) => {
721
730
let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -734,8 +743,12 @@ where
734
743
dest : & impl Writeable < ' tcx , M :: Provenance > ,
735
744
) -> InterpResult < ' tcx > {
736
745
match self . as_mplace_or_mutable_local ( & dest. to_place ( ) ) ? {
737
- Right ( ( local_val, _local_layout) ) => {
746
+ Right ( ( local_val, _local_layout, local ) ) => {
738
747
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
+ }
739
752
}
740
753
Left ( mplace) => {
741
754
let Some ( mut alloc) = self . get_place_alloc_mut ( & mplace) ? else {
@@ -941,7 +954,7 @@ where
941
954
mplace. mplace ,
942
955
) ?;
943
956
}
944
- M :: after_local_allocated ( self , local, & mplace) ?;
957
+ M :: after_local_moved_to_memory ( self , local, & mplace) ?;
945
958
// Now we can call `access_mut` again, asserting it goes well, and actually
946
959
// overwrite things. This points to the entire allocation, not just the part
947
960
// the place refers to, i.e. we do this before we apply `offset`.
0 commit comments