@@ -320,31 +320,35 @@ impl<'mir, 'tcx: 'mir> StoreBuffer {
320
320
keep_searching = if store_elem. timestamp <= clocks. clock [ store_elem. store_index ] {
321
321
// CoWR: if a store happens-before the current load,
322
322
// then we can't read-from anything earlier in modification order.
323
+ // C++20 §6.9.2.2 [intro.races] paragraph 18
323
324
log:: info!( "Stopping due to coherent write-read" ) ;
324
325
false
325
326
} else if store_elem. loads . borrow ( ) . iter ( ) . any ( |( & load_index, & load_timestamp) | {
326
327
load_timestamp <= clocks. clock [ load_index]
327
328
} ) {
328
329
// CoRR: if there was a load from this store which happened-before the current load,
329
330
// then we cannot read-from anything earlier in modification order.
331
+ // C++20 §6.9.2.2 [intro.races] paragraph 16
330
332
log:: info!( "Stopping due to coherent read-read" ) ;
331
333
false
332
334
} else if store_elem. timestamp <= clocks. fence_seqcst [ store_elem. store_index ] {
333
- // The current load, which may be sequenced-after an SC fence, can only read-from
334
- // the last store sequenced-before an SC fence in another thread (or any stores
335
- // later than that SC fence)
335
+ // The current load, which may be sequenced-after an SC fence, cannot read-before
336
+ // the last store sequenced-before an SC fence in another thread.
337
+ // C++17 §32.4 [atomics.order] paragraph 6
336
338
log:: info!( "Stopping due to coherent load sequenced after sc fence" ) ;
337
339
false
338
340
} else if store_elem. timestamp <= clocks. write_seqcst [ store_elem. store_index ]
339
341
&& store_elem. is_seqcst
340
342
{
341
- // The current non-SC load can only read-from the latest SC store (or any stores later than that
342
- // SC store)
343
+ // The current non-SC load, which may be sequenced-after an SC fence,
344
+ // cannot read-before the last SC store executed before the fence.
345
+ // C++17 §32.4 [atomics.order] paragraph 4
343
346
log:: info!( "Stopping due to needing to load from the last SC store" ) ;
344
347
false
345
348
} else if is_seqcst && store_elem. timestamp <= clocks. read_seqcst [ store_elem. store_index ] {
346
- // The current SC load can only read-from the last store sequenced-before
347
- // the last SC fence (or any stores later than the SC fence)
349
+ // The current SC load cannot read-before the last store sequenced-before
350
+ // the last SC fence.
351
+ // C++17 §32.4 [atomics.order] paragraph 5
348
352
log:: info!( "Stopping due to sc load needing to load from the last SC store before an SC fence" ) ;
349
353
false
350
354
} else { true } ;
0 commit comments