@@ -648,18 +648,17 @@ impl MemoryCellClocks {
648648 thread_clocks. clock . index_mut ( index) . span = current_span;
649649 }
650650 thread_clocks. clock . index_mut ( index) . set_read_type ( read_type) ;
651- if self . write_was_before ( & thread_clocks. clock ) {
652- // We must be ordered-after all atomic writes.
653- let race_free = if let Some ( atomic) = self . atomic ( ) {
654- atomic. write_vector <= thread_clocks. clock
655- } else {
656- true
657- } ;
658- self . read . set_at_index ( & thread_clocks. clock , index) ;
659- if race_free { Ok ( ( ) ) } else { Err ( DataRace ) }
660- } else {
661- Err ( DataRace )
651+ // Check synchronization with non-atomic writes.
652+ if !self . write_was_before ( & thread_clocks. clock ) {
653+ return Err ( DataRace ) ;
662654 }
655+ // Check synchronization with atomic writes.
656+ if !self . atomic ( ) . is_none_or ( |atomic| atomic. write_vector <= thread_clocks. clock ) {
657+ return Err ( DataRace ) ;
658+ }
659+ // Record this access.
660+ self . read . set_at_index ( & thread_clocks. clock , index) ;
661+ Ok ( ( ) )
663662 }
664663
665664 /// Detect races for non-atomic write operations at the current memory cell
@@ -675,24 +674,21 @@ impl MemoryCellClocks {
675674 if !current_span. is_dummy ( ) {
676675 thread_clocks. clock . index_mut ( index) . span = current_span;
677676 }
678- if self . write_was_before ( & thread_clocks. clock ) && self . read <= thread_clocks. clock {
679- let race_free = if let Some ( atomic) = self . atomic ( ) {
680- atomic. write_vector <= thread_clocks. clock
681- && atomic. read_vector <= thread_clocks. clock
682- } else {
683- true
684- } ;
685- self . write = ( index, thread_clocks. clock [ index] ) ;
686- self . write_type = write_type;
687- if race_free {
688- self . read . set_zero_vector ( ) ;
689- Ok ( ( ) )
690- } else {
691- Err ( DataRace )
692- }
693- } else {
694- Err ( DataRace )
677+ // Check synchronization with non-atomic accesses.
678+ if !( self . write_was_before ( & thread_clocks. clock ) && self . read <= thread_clocks. clock ) {
679+ return Err ( DataRace ) ;
695680 }
681+ // Check synchronization with atomic accesses.
682+ if !self . atomic ( ) . is_none_or ( |atomic| {
683+ atomic. write_vector <= thread_clocks. clock && atomic. read_vector <= thread_clocks. clock
684+ } ) {
685+ return Err ( DataRace ) ;
686+ }
687+ // Record this access.
688+ self . write = ( index, thread_clocks. clock [ index] ) ;
689+ self . write_type = write_type;
690+ self . read . set_zero_vector ( ) ;
691+ Ok ( ( ) )
696692 }
697693}
698694
@@ -1201,7 +1197,7 @@ impl VClockAlloc {
12011197 /// operation for which data-race detection is handled separately, for example
12021198 /// atomic read operations. The `ty` parameter is used for diagnostics, letting
12031199 /// the user know which type was read.
1204- pub fn read < ' tcx > (
1200+ pub fn read_non_atomic < ' tcx > (
12051201 & self ,
12061202 alloc_id : AllocId ,
12071203 access_range : AllocRange ,
@@ -1243,7 +1239,7 @@ impl VClockAlloc {
12431239 /// being created or if it is temporarily disabled during a racy read or write
12441240 /// operation. The `ty` parameter is used for diagnostics, letting
12451241 /// the user know which type was written.
1246- pub fn write < ' tcx > (
1242+ pub fn write_non_atomic < ' tcx > (
12471243 & mut self ,
12481244 alloc_id : AllocId ,
12491245 access_range : AllocRange ,
0 commit comments