Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c731071

Browse files
committed
Give flag temp disabling race detector a better name
1 parent 8215702 commit c731071

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/concurrency/data_race.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
455455
fn allow_data_races_ref<R>(&self, op: impl FnOnce(&MiriEvalContext<'mir, 'tcx>) -> R) -> R {
456456
let this = self.eval_context_ref();
457457
if let Some(data_race) = &this.machine.data_race {
458-
data_race.ongoing_atomic_access.set(true);
458+
data_race.ongoing_action_data_race_free.set(true);
459459
}
460460
let result = op(this);
461461
if let Some(data_race) = &this.machine.data_race {
462-
data_race.ongoing_atomic_access.set(false);
462+
data_race.ongoing_action_data_race_free.set(false);
463463
}
464464
result
465465
}
@@ -474,11 +474,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
474474
) -> R {
475475
let this = self.eval_context_mut();
476476
if let Some(data_race) = &this.machine.data_race {
477-
data_race.ongoing_atomic_access.set(true);
477+
data_race.ongoing_action_data_race_free.set(true);
478478
}
479479
let result = op(this);
480480
if let Some(data_race) = &this.machine.data_race {
481-
data_race.ongoing_atomic_access.set(false);
481+
data_race.ongoing_action_data_race_free.set(false);
482482
}
483483
result
484484
}
@@ -1151,8 +1151,9 @@ pub struct GlobalState {
11511151
multi_threaded: Cell<bool>,
11521152

11531153
/// A flag to mark we are currently performing
1154-
/// an atomic access to supress data race detection
1155-
ongoing_atomic_access: Cell<bool>,
1154+
/// a data race free action (such as atomic access)
1155+
/// to supress the race detector
1156+
ongoing_action_data_race_free: Cell<bool>,
11561157

11571158
/// Mapping of a vector index to a known set of thread
11581159
/// clocks, this is not directly mapping from a thread id
@@ -1205,7 +1206,7 @@ impl GlobalState {
12051206
pub fn new() -> Self {
12061207
let mut global_state = GlobalState {
12071208
multi_threaded: Cell::new(false),
1208-
ongoing_atomic_access: Cell::new(false),
1209+
ongoing_action_data_race_free: Cell::new(false),
12091210
vector_clocks: RefCell::new(IndexVec::new()),
12101211
vector_info: RefCell::new(IndexVec::new()),
12111212
thread_info: RefCell::new(IndexVec::new()),
@@ -1232,14 +1233,14 @@ impl GlobalState {
12321233
}
12331234

12341235
// We perform data race detection when there are more than 1 active thread
1235-
// and we are not currently in the middle of an atomic acces where data race
1236-
// is impossible
1236+
// and we have not temporarily disabled race detection to perform something
1237+
// data race free
12371238
fn race_detecting(&self) -> bool {
1238-
self.multi_threaded.get() && !self.ongoing_atomic_access.get()
1239+
self.multi_threaded.get() && !self.ongoing_action_data_race_free.get()
12391240
}
12401241

1241-
pub fn ongoing_atomic_access(&self) -> bool {
1242-
self.ongoing_atomic_access.get()
1242+
pub fn ongoing_action_data_race_free(&self) -> bool {
1243+
self.ongoing_action_data_race_free.get()
12431244
}
12441245

12451246
// Try to find vector index values that can potentially be re-used

src/concurrency/weak_memory.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl StoreBufferAlloc {
139139
/// after all the prior atomic accesses so the location no longer needs to exhibit
140140
/// any weak memory behaviours until further atomic accesses.
141141
pub fn memory_accessed<'tcx>(&self, range: AllocRange, global: &GlobalState) {
142-
if !global.ongoing_atomic_access() {
142+
if !global.ongoing_action_data_race_free() {
143143
let mut buffers = self.store_buffers.borrow_mut();
144144
let access_type = buffers.access_type(range);
145145
match access_type {
@@ -420,7 +420,9 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
420420
&& !alloc_clocks
421421
.race_free_with_atomic(range, this.machine.data_race.as_ref().unwrap())
422422
{
423-
throw_ub_format!("racy imperfectly overlapping atomic access is not possible in the C++20 memory model");
423+
throw_ub_format!(
424+
"racy imperfectly overlapping atomic access is not possible in the C++20 memory model"
425+
);
424426
}
425427
}
426428
Ok(())

0 commit comments

Comments
 (0)